I'm completely new to javascript, but in my eyes this should work.
But then again, i'm quite an idiot myself and it's usually a very very simple problem that someone will see in 5 seconds. I want the header (supposed to be in variable 'itemname') to be put into variable item1, then the alertbox to come up with the string that was inserted into the variable.
Say if the header had the word 'Hello' in it, then when you click a button, 'Hello' would come up in an alert. And if the header had the word 'Goodbye', then the alert would say 'Goodbye'.
<script type="text/javascript">
function alert() {
var item1 = document.getElementById("itemname");
alert(item1);
}
</script>
(next snippet is the html)
<h1 id=”itemname”>
Hello
</h1>
Shouldn't this work? All it does is show 'null'.
Thanks for the help.
edit: lol, i was right. figured it out about 20 minutes after this thread. just remade the code exactly the same way and it worked. no clue what happened, but yeah. solved..