<a href="$val[description]" class="product_hov">
<p class="pv">
<p class="dii" onMouseOver="this.style.backgroundColor='#00755D'" onMouseOut="this.style.backgroundColor='#DADADA'">
<img src="$val[imgurl]" alt="$val[title]" title="$val[title]" width="{$lang_imgwidth}" height="{$lang_imgheight}" class="product_img" onMouseOver="change_img_product(this,'$val[imgurls]')" onMouseOut="change_imgs_product(this,'$val[imgurl]')"/>
<p class="product_di">
<dd clss="product_nm">$val[title]</dd>
<p class="product_long">
<font class="product_wz" style="text-align: center;">$val[issue]</font>
</p>
</p>
</a>
Now the image src is changed when the mouse stays on the img. I want to add the Onmouse attribute directly to the a link. How to find the node of this img and change the src of the img? Thank you
function change_img_product(obj,img){
$(obj).attr("src",img);
}
function change_imgs_product(obj,img){
$(obj).attr("src",img);
}
ringa_lee2017-05-18 10:52:30
You add a class or id to the img tag. When the mouse is on the a tag, you can find the corresponding class or id and find the img. Then switch the img src value
给我你的怀抱2017-05-18 10:52:30
<a hreef="" class="product_hov">
.....
<img src="初始化图片地址" _src="新图片地址" />
.....
</a>
$('.product_hov img').on('mouseover',function () {
var _src = $(this).attr('_src');
$(this).src(_src);
});
世界只因有你2017-05-18 10:52:30
You guys, this is specifically
$("a").hover(function(){
// Go in
$(this).find('img').src('')
},function(){
$(this).find ('img').src('')
//come out
});