I have a pretty straightforward snippet of JS/jQuery I’m using to extract some content from a page:
(function (idx) {
var product = $(".product_wrapper img")[idx];
return (product && product.src) ? product.src.match(/([^]+)\\_/)[1] : ""
}(0)).split('_')[1]
Works just fine in most browsers, but IE7 & IE8 are throwing errors. In IE7 the error message reads [object Error] and in IE8 it reads SyntaxError: Expected '/'.
Anybody know what’s wrong with this code? Am I using some syntactic sugar that MSIE doesn’t like? Been puzzling over this one and I’m stumped.
if
product.src.match(/([^]+)\\_/)is nullproduct.src.match(/([^]+)\\_/)[1]will cause object Error