The code copy is as follows:
<ul id="newslist">
<li> <span>2013-06-24</span>
<span >/span>
<span><a href="{href}" onmouseover="javascript:changeReadIconOver(this);" onmouseout="javascript:changeReadIconOut(this);">Be healthy and everything goes well</a></span>'
</li>
</ul>
If you want to find a span with icon class (operate it, replace news_list_icon with news_list_icon_hover), in addition to using the original code
The code copy is as follows:
$("#newslist li").hover(function(){
$("#newslist li").find(".icon").addClass("news_list_icon_hover") },function(){ $("#newslist li").find(".icon").removeClass("news_list_icon_hover") } );
You can also use the parent query method to locate it, as follows:
The code copy is as follows:
function changeReadIconOver(alink) {
$(link).parent().parent().find(".icon").addClass("news_list_icon_hover");
}
function changeReadIconOut(link) {
$(link).parent().parent().find(".icon").removeClass("news_list_icon_hover");
}
$(alink).parent(): refers to the tag <span>
$(alink).parent().parent(): refers to the <li> tag $(alink).parent().parent().find(".icon"): You can locate the desired element.