henryaaron
henryaaron

Reputation: 6192

jQuery object does not support this property or method

I have a code like this:

$(function() {
if ($("div#ProductDetail_ProductDetails_div2 table tbody tr").text().trim() == '') {
    $("div#ProductDetail_ProductDetails_div2").css("border", "0px");
    $("div#ProductDetail_ProductDetails_div").css({'border-bottom-left-radius' : '5px', '-moz-border-bottom-left-radius' : '5px', '-webkit-border-bottom-left-radius' : '5px', 'border-bottom-right-radius' : '5px', '-moz-border-bottom-right-radius' : '5px', '-webkit-border-bottom-right-radius' : '5px'});
}
});

Basically, it says if there is no content nested inside the <tr> , run some CSS modifications...

However, in IE8's debug console it says on this line if ($("div#ProductDetail_ProductDetails_div2 table tbody tr").text().trim() == '') { "object does not support this property or method" I have no clue what that means.

This is causing some problems with the other jQuery on the site. I know that when I comment it out, the site works perfectly. Can anybody tell me what's wrong the code that making IE complain? Thanks.

Upvotes: 1

Views: 469

Answers (1)

Shyju
Shyju

Reputation: 218722

jquery trim function is like this

jQuery.trim( str )

and you probably need to get the td text value to compare.

Change it like this

if ($.trim($("div#ProductDetail_ProductDetails_div2 table tbody tr td:first").text())=="")
{
 //  Rest of the code

http://api.jquery.com/jQuery.trim/

Upvotes: 5

Related Questions