Is the DOM loaded when the script starts? If you do not use this code in window.onload or put it at the end of the body, then the elements do not exist when it is executed.
Try placing the script only inside the closing </body> .
<body> <script type="text/javascript"> alert($('content').innerHTML); </script> </body>
Also, your first line selects correctly, but will return an array of elements, so innerHTML will be undefined .
To iterate over an array, you can do this:
$$('.mnu_item').each(function(val,i) { alert(val.innerHTML); });
or if you want to get an array from innerHTML values, follow these steps:
var values = $$('.mnu_item').map(function(val,i) { return val.innerHTML; });
user113716
source share