alecks Posted February 21, 2008 Share Posted February 21, 2008 I know some basic javascript, but I'm pretty much a newbie to it. What I want to do I think is pretty simple, but I cannot find any guidance on it. Please help I have a couple of links like <a href="" id="about">about</a> and a header <h1 id="description">description</h1>. When the links are hovered over, I want to change 'description' to be a description of the link. I can do this with onMouseOver, but that is not xhtml valid and I would like it to be, if possible. How do I do this? Thanks Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 21, 2008 Share Posted February 21, 2008 I think that the onmouseover event is going to be about the only way your going to be able to do this. Quote Link to comment Share on other sites More sharing options...
nogray Posted February 21, 2008 Share Posted February 21, 2008 you can try to add it the event from a script <script type="text/javascript"> document.getElementById('about').onmouseover = function(){ document.getElementById('description').innerHTML = "whatever"; }; </script> Quote Link to comment Share on other sites More sharing options...
alecks Posted February 21, 2008 Author Share Posted February 21, 2008 HA turns out it is valid xhtml, it just cannot be camel case! xD Quote Link to comment Share on other sites More sharing options...
alecks Posted February 21, 2008 Author Share Posted February 21, 2008 you can try to add it the event from a script <script type="text/javascript"> document.getElementById('about').onmouseover = function(){ document.getElementById('description').innerHTML = "whatever"; }; </script> hmm this doesnt seem to work :/ Quote Link to comment Share on other sites More sharing options...
nogray Posted February 21, 2008 Share Posted February 21, 2008 make sure you call teh JS after the page has loaded (onload event) Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 22, 2008 Share Posted February 22, 2008 XHTML can NOT have any uppercase attributes or tags, only values and everything MUST have a closing tag or be self closed: <br /> and all attributes MUST have a value so that means no more <option selected> it would be <option selected="selected"> Little off topic sorry... Quote Link to comment Share on other sites More sharing options...
alecks Posted February 22, 2008 Author Share Posted February 22, 2008 make sure you call teh JS after the page has loaded (onload event) how, exactly? thanks Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 22, 2008 Share Posted February 22, 2008 </body> <script type="text/javascript"> myFunction(); </script> Quote Link to comment Share on other sites More sharing options...
phpQuestioner_v5.0 Posted February 22, 2008 Share Posted February 22, 2008 </body> <script type="text/javascript"> myFunction(); </script> You'll probably need to call an onload event with that function; to make sure it triggers without any errors. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.