JQuery document function ready to work in IE

I have a function that I use to replace some text output with a button or a sold label, respectively.

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>"); } }) }); 

In most browsers, it works fine, but the client complains that it does not work in IE9. When I test it on my computer, it works most of the time, but sometimes it is not, and every time I test it on browsers, it does not work. It appears in browsershots.org tests, as if jQuery didn't even start.

+7
source share
1 answer
Console

not defined in IE9, change your code like

 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>"); } }) }); 
+7
source

All Articles