Saturday 4 June 2011

How do you make the text in a link change when you put your mouse over it? (HTML)?

It is a link and it says Frank N. Furter and when I put my mouse on it I want it to say A Scientist! How do I do this?





%26lt;a href=%26quot;frank.html%26quot;%26gt;Frank N. Furter%26lt;/a%26gt;|||The simplest solution that I can think of is to use the onmouseover and onmouseout event attributes to change this.innerHTML as in:





%26lt;a href=%26quot;frank.html%26quot; onmouseover=%26quot;this.innerHTML=%26#039;A Scientist!%26#039;%26quot; onmouseout=%26quot;this.innerHTML=%26#039;Frank N. Furter%26#039;%26quot;%26gt;Frank N. Furter%26lt;/a%26gt;





For more on other attributes you can use with the HTML A Tag see: http://www.html-tags-guide.com/html-a-ta鈥?/a>|||http://www.web-source.net/web_design_tip鈥?/a>|||%26lt;script type=%26quot;text/javascript%26quot;%26gt;


%26lt;!--


function changeText(id,text)


{


var obj = document.getElementById(id);


obj.innerHTML=text;


}


//--%26gt;


%26lt;/script%26gt;





%26lt;a href=%26quot;frank.html%26quot; id=%26quot;frank%26quot; onmouseover=%26quot;changeText(%26#039;frank%26#039;,%26#039;A Scientist!%26#039;)%26quot; onmouseout=%26quot;changeText(%26#039;frank%26#039;,%26#039;Frank N. Furter%26#039;)%26quot;%26gt;Frank N. Furter%26lt;/a%26gt;