日期:2014-05-16  浏览次数:20357 次

鼠标移动到某张图片时如何让文字跟着改变
当鼠标移动到某张图片时(onmouseover)如何让文字跟着改变
当鼠标移出的时候(onmouseout)文字再变回来
用javascript来怎么写?

谢谢

------解决方案--------------------
<img src= "1.jpg " onmouseover= "document.getElementById( 'word ').innerHTML= '文字1 ' " onmouseout= "document.getElementById( 'word ').innerHTML= '文字2 ' " />
<span id= "word "> 文字2 </span>
------解决方案--------------------
<img src= "http://zi.csdn.net/120.60auto1.22.gif " onmouseover= "document.getElementById( 'message ').innerHTML= '在上面 ' " onmouseout= "document.getElementById( 'message ').innerHTML= '出去了 ' "/>
<a id= "message " href= "# "> 测试文字 </a>

------解决方案--------------------
<img src= "1.jpg " title= "图片的文字 "
onmouseover= "document.getElementById( 'word ').innerHTML=this.title " onmouseout= "document.getElementById( 'word ').innerHTML=document.getElementById( 'word ').title " />
<a href= "# " id= "word " title= "原来的文字 "> 原来的文字 </a>