JQuery文档就绪功能无法在IE中运行

Sco*_*ter 7 jquery internet-explorer domdocument

我有一个功能,我用来替换一些文本输出与按钮或售罄标签相应.

jQuery(document).ready(function() {
jQuery('td.register').each(function () {
    var text = jQuery(this).text();
    var exploded = text.split(',');
    console.log(exploded[0]);
    console.log(exploded[1]);
    if (exploded[0] == 0) {
        jQuery(this).html("<font color='red'>SOLD OUT</font>");
    } else {
        jQuery(this).html("<a class='button' title ='Register for this event' href='" + exploded[1] + "'>Register</a>"); 
    }
})
});
Run Code Online (Sandbox Code Playgroud)

它似乎在大多数浏览器上工作正常,但客户端在IE9中抱怨它不起作用.当我在我的计算机上测试它时,大部分时间它都可以工作,但有时它没有,每次我在browsershots.org上测试它都不起作用.它出现在browsershots.org测试中,好像jQuery甚至没有运行.

dak*_*ait 7

控制台没有在IE9中定义修改你的代码就好

jQuery(document).ready(function() {
jQuery('td.register').each(function () {
    var text = jQuery(this).text();
    var exploded = text.split(',');
    if(typeof(console)!='undefined'){
        console.log(exploded[0]);
        console.log(exploded[1]);
    }
    if (exploded[0] == 0) {
        jQuery(this).html("<font color='red'>SOLD OUT</font>");
    } else {
        jQuery(this).html("<a class='button' title ='Register for this event' href='" + exploded[1] + "'>Register</a>"); 
    }
})
});
Run Code Online (Sandbox Code Playgroud)