Hello guys I would like some help since I am new to JS I expect this piece of code to show an alert with the href of the element "aaa" but nothing happens. Could you explain what I am doing wrong? thanks
<html>
<body>
<script type="text/javascript">
function myFunction(){
var xxx = document.getElementById("aaa").href;
alert(xxx);
}
myFunction();
</script>
<a href="Moody'sKMVproject-studentsample2.doc" id="aaa">file word</a>
</body>
</html>
Please delete this question as it is a duplicate of Why does jQuery or a DOM method such as getElementById not find the element?
I am sorry for posting .. I am new to JS and I didn't know what to search for in the first place