Wednesday, November 24, 2010

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;How do you make the text in a link change when you put your mouse over it? (HTML)?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='A Scientist!'%26quot; onmouseout=%26quot;this.innerHTML='Frank N. Furter'%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-taHow do you make the text in a link change when you put your mouse over it? (HTML)?http://www.web-source.net/web_design_tipHow do you make the text in a link change when you put your mouse over it? (HTML)?%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('frank','A Scientist!')%26quot; onmouseout=%26quot;changeText('frank','Frank N. Furter')%26quot;%26gt;Frank N. Furter%26lt;/a%26gt;