How to access an HTML element from JavaScript :
Using document.getElementById(id) method.
document.getElementById("demo").innerHTML="Test code";
Simple example :
<!DOCTYPE html>
<html>
<body>
<div id="Test">Test Code</p>
<script>
document.getElementById("demo").innerHTML="Test code";
</script>
</body>
</html>
<html>
<body>
<div id="Test">Test Code</p>
<script>
document.getElementById("demo").innerHTML="Test code";
</script>
</body>
</html>
Output :
Test code
No comments:
Post a Comment