Bill Greer
Bill Greer

Reputation: 3156

Why does this script not work in IE8?

I am using jquery 1.10.2 and the following call to my dialogOpen function works fine in IE9+ but I am getting the following error in IE8:

Object does not support this property or method. Any ideas ?

dialogOpen($(this).attr("id"), $(this).find(".tdStyle").html().trim(),     $(this).find(".tdQtyOnHand").html().trim(), $(this),  $(this).find(".tdPlantID").html().trim());

Thanks

Upvotes: 1

Views: 92

Answers (1)

Jason Sperske
Jason Sperske

Reputation: 30416

.html() returns a String object and IE doesn't support the .trim() method on String, fortunately jQuery provides an alternative, $.trim(String). You can also add it yourself (but honestly with jQuery already loaded why would you) by following this exhaustive article (which would allow you to keep your original code entirely unmodified):

if (!String.prototype.trim) {
  String.prototype.trim = function () {
    return this.replace(/^\s+|\s+$/gm, '');
  };
}

Upvotes: 4

Related Questions