+ 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
3 Answers
+ 2
Try this:
<body>
<div id="text"></div>
<script>
var text = document.getElementById("text");
text.innerText = "text fr Javascript!";
</script>
</body>
+ 4
Sushant Dhiman Can you please elaborate more.
+ 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