繁体   English   中英

jQuery / Javascript没有在IE7中运行

[英]jQuery/Javascript not running in IE7

以下脚本未在IE7中运行,但在IE 8 + 9和所有其他浏览器中运行良好。 甚至放入alert("something"); 不起作用 - 我有另一个工作正常的脚本,它完全在IE 7中运行。

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>

我错过了DOCTYPE吗? 这是下面的脚本;

var formPageTitle = $("div.hsRadarform td h3").text(); 

$('.AspNet-DataList td a').each(function (index) {        
    var listElementText = $(this).text();
    var shade = "faint";

    if(formPageTitle.toLowerCase() == listElementText.toLowerCase()) {
        shade = "dark";
    }

    //adding the numbered circles here using jQuery
    $(this).css({ 
        'background-image': 'url(/assets/img/radarstep' + (index + 1) + shade + '.png)',
        'background-repeat': 'no-repeat',
        'height': '25px',
        'width': '25px',
    });
});

使用尾随逗号,IE非常挑剔:

$(this).css({ 'background-image': 'url(/assets/img/radarstep' + (index + 1) + shade + '.png)',
    'background-repeat': 'no-repeat',
    'height': '25px',
    'width': '25px',
});

应该

$(this).css({ 'background-image': 'url(/assets/img/radarstep' + (index + 1) + shade + '.png)',
    'background-repeat': 'no-repeat',
    'height': '25px',
    'width': '25px' // comma removed
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM