读书人

js怎么在HTML里面做成 鼠标移下去换文

发布时间: 2012-10-11 10:16:10 作者: rapoo

js如何在HTML里面做成 鼠标移上去换文字
有好多链接标签如:
<a id="re" alt="新闻">News</a>
<a id="re" alt="产品">Products</a>
<a id="re" alt="其它">Other</a>
我想让鼠标移到比如News链接上时, News这几个字就换为中文“新闻”。
请问这个JS该怎么写呀?

[解决办法]

HTML code
<html><head><script>function changeShow(obj){ obj.innerText="123123123123";}</script></head><body><a id="re" alt="asdf" onmouseover="changeShow(this);">News</a></body></html>
[解决办法]
function check(obj){
obj.title=obj.innerText;
obj.innerText=obj.alt;
obj.alt=obj.title;
}

<a id="re" onmouseover="check(this)" onmouseout="check(this)" alt="新闻">News</a>
<a id="re" onmouseover="check(this)" onmouseout="check(this)" alt="产品">Products</a>
<a id="re" onmouseover="check(this)" onmouseout="check(this)" alt="其它">Other</a>

读书人网 >Java Web开发

热点推荐