Difference between revisions of "Main Page"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
+ | <!DOCTYPE html> | ||
<html> | <html> | ||
− | < | + | <head> |
+ | <style> | ||
+ | .anchors { | ||
+ | display: block; | ||
+ | padding: 5px; | ||
+ | background-color: black; | ||
+ | color: white; | ||
+ | } | ||
+ | |||
+ | #myAnchor { | ||
+ | background-color: dodgerblue; | ||
+ | } | ||
+ | </style> | ||
+ | </head> | ||
+ | <body> | ||
+ | |||
+ | <a class="anchors" id="myAnchor" href="https://www.w3schools.com/html/">HTML</a> | ||
+ | <a class="anchors" href="https://www.w3schools.com/css/">CSS</a> | ||
+ | <a class="anchors" href="https://www.w3schools.com/js/">JavaScript</a> | ||
+ | |||
+ | <p>Click the button to display the value of the id attribute of the first link above.</p> | ||
+ | |||
+ | <button onclick="myFunction()">Try it</button> | ||
+ | |||
+ | <p id="demo"></p> | ||
<script> | <script> | ||
− | + | function myFunction() { | |
− | + | var x = document.getElementsByClassName("anchors")[0].id; | |
− | + | document.getElementById("demo").innerHTML = x; | |
− | } | + | } |
</script> | </script> | ||
− | + | </body> | |
</html> | </html> |
Revision as of 14:50, 6 April 2020
<!DOCTYPE html> HTML CSS JavaScript
Click the button to display the value of the id attribute of the first link above.