+ 2

How can i add JavaScript to a specific html tags

how to add javascript to specific html code tell me. i mean if i had to add javascript in button tag of html how to do

18th Jun 2018, 4:29 AM
Sushant
Sushant - avatar
3 Réponses
+ 2
Try this: <body> <div id="text"></div> <script> var text = document.getElementById("text"); text.innerText = "text fr Javascript!"; </script> </body>
18th Jun 2018, 5:37 AM
Calviղ
Calviղ - avatar
+ 4
Sushant Dhiman Can you please elaborate more.
18th Jun 2018, 4:36 AM
Akash Pal
Akash Pal - avatar
+ 1
the button would be this code <input id=“id” type=“button” value=“name” onclick=“submit()”> replace name with what ever you want and replace submit to anything but keep the brackets and change id to your intrest the javascript function submit() { document.getElementById(“id”).innerHTML = “submit”; } Here is my one code to show you how to add action to the button https://code.sololearn.com/WlU4Dr4aFK7W/?ref=app simply look at the bottom button and the javascript
18th Jun 2018, 10:00 AM
Cryonic
Cryonic - avatar