CurlyFro
CurlyFro

Reputation: 1882

jQuery selector not working in IE

sample html:

<tr>
    <td class="hidden tblLnk">8163</td> 
</tr>
<tr>
    <td class="hidden tblLnk">8163</td> 
</tr>
<tr>
    <td class="hidden tblLnk">8164</td> 
</tr>

this method should return a unique array of text from rows with a specific td class. { 8163, 8164 } in our sample.

works in ffs and chrome but not in ie8 or safari. can you spot the problem?

function getUniqueIds()
{
     var tblLnks = new Array();

     $('td.tblLnk').each(function()
     {
        tblLnks.push($(this).text().trim());
     });

     return tblLnks.unique();
}

Upvotes: 0

Views: 177

Answers (2)

user113716
user113716

Reputation: 322462

I think this:

$(this).text().trim()

should be this:

$.trim($(this).text());

If your intention is to us jQuery's trim() function.

Upvotes: 2

anddoutoi
anddoutoi

Reputation: 10111

1st: There is no native unique() method on the Array object in JavaScript that works in all A-grade browsers as of today. So if this is your intention, please post that code aswell.

2nd: If you refer to the unique() method of jQuery you better read up on the description of that method. This method can´t be called on the Array object. It takes an Array object of DOM elements as a paramenter, e.g.:

$.unique(myArrayOfDomElements);

Upvotes: 1

Related Questions