首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

jquery兼容有关问题 ie7

2013-03-01 
jquery兼容问题ie7$(function () {$(.qnmimg ).each(function (i, n) {$(n).attr(onmouseover, fnSet

jquery兼容问题 ie7


  $(function () {
        $(".qnmimg ").each(function (i, n) {
            $(n).attr("onmouseover", "fnSetImgsrc('" + $(n).attr("alt") + "')");
            
        });

    });
//    
    function fnSetImgsrc(srcstr) {     
        $("#imgmain").attr("src", srcstr);
    }  
  

在ie8,9中均正确执行,在ie7里我断电了一下,根本没有执行进 $(n).attr("onmouseover", "fnSetImgsrc('" + $(n).attr("alt") + "')");
求大家指教,谢谢了!
[解决办法]
lz,犯了一个低级错误, js注册事件不能这样写$(n).attr("onmouseover", "fnSetImgsrc('" + $(n).attr("alt") + "')");

改成下面就可以了,不能因为你调用方便就随便写

 $(n).mouseover(function()
{
fnSetImgsrc( $(this).attr("alt"));
})

热点排行