Reputation: 11
this should work, I am just trying to contact a node and find out it's value.
<html>
<head></head>
<body>
<script type="text/javascript">
function nadfunc() {
var demoList = document.getElementById('eventsList');
alert(var);
}
nadfunc();
</script>
<ul id="eventsList">
<li>List</li>
<li>List</li>
<li>
<a id="linkedItem" href="http://www.google.com">Linked List Item</a>
</li>
<li>List</li>
</ul>
</body>
</html>
Upvotes: 1
Views: 1662
Reputation: 6265
write
alert(demoList);
var
is just a keyword, you have to use actual variable name.
Also, Your script block should be placed at the end of the page before closing body tag:
<html>
<head></head>
<body>
<ul id="eventsList">
<li>List</li>
<li>List</li>
<li><a id="linkedItem" href="http://www.google.com">Linked List Item</a></li>
<li>List</li>
</ul>
<script type="text/javascript">
function nadfunc() {
var demoList = document.getElementById('eventsList');
alert(demoList);
}
nadfunc();
</script>
</body>
</html>
Upvotes: 9