更改图像src onMouseOver

时间:2015-03-25 13:46:22

标签: css angularjs

HTML:

<span class="btn-cover">
  <img src="../assets/images/btn_page_back_normal.png"  onmouseover="../assets/images/btn_page_back_normal.png" class="date-left" >
</span>

我无法对img标签进行悬停效果,试图用angular.js替换不同的图像。

我喜欢问题所在,因为你需要别人的帮助,不起作用。

1 个答案:

答案 0 :(得分:5)

您需要将图像的src设置为新的

<span class="btn-cover">
  <img src="../assets/images/btn_page_back_normal.png"  
  onmouseover="this.src='../assets/images/btn_page_back_normal.png'" 
onmouseout="this.src='../assets/images/btn_page_back_normal.png'" 
class="date-left" >
</span>

<强>演示

&#13;
&#13;
<span class="btn-cover">
  <img src="https://www.ricoh.com/r_dc/r/r8/img/sample_08.jpg"  
  onmouseover="this.src='http://www.scanseri.fi/wp-content/uploads/2014/05/sample.jpg'" 
onmouseout="this.src='https://www.ricoh.com/r_dc/r/r8/img/sample_08.jpg'" 
class="date-left" height="100" width="100">
</span>
&#13;
&#13;
&#13;