Using "untidy" HTML code can result in JavaScript errors. These two JavaScript statements will produce different results: |
Example:
HTML
<script>
// Only paragraph 2 will be overwritten
document.getElementById("demo").innerHTML = "HELLO.";
</script>
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p id="Demo">This is paragraph 1.</p>
<p id="demo">This is paragraph 2.</p>
<script>
// Only paragraph 2 will be overwritten
document.getElementById("demo").innerHTML = "HELLO.";
</script>
</body>
</html>
Reffered: https://www.w3schools.com/html/html5_syntax.asp
Example of Accessing HTML Elements with JavaScript | HTML Style Guide |
Full Example of Accessing HTML Elements with JavaScript | HTML Style Guide |
Read Full: | HTML Style Guide |
Category: | Web Tutorial |
Sub Category: | HTML Style Guide |
Uploaded: | 11 months ago |
Uploaded by: | Admin |
Views: | 47 |