Abs
Abs

Reputation: 57916

Works in Firefox but not IE

I make use of the following to find a string in a particular element, if it exists, tick a checkbox. This works great on Firefox but not internet explorer (8). I am having trouble finding why.

$.fn.searchString = function(str) {
   return this.filter('*:contains("' + str + '")');
};

var myID = $('div').searchString(files_array[i].substr(-4));

alert(myID);//[object object]

alert(myID.children());//[object object]

myID.children().attr('checked', true);//does not tick checkbox

alert(myID.children().attr('checked'));//undefined

Does IE not like the children() function?

Thanks all for any help

Upvotes: 3

Views: 195

Answers (2)

Pointy
Pointy

Reputation: 413702

From MSDN, in reference to the "substr" function:

Remarks

If length is zero or negative, an empty string is returned. If not specified, the substring continues to the end of the string.

You're coming up with nothing from the original code that tries to set "myID".

Upvotes: 2

Kangkan
Kangkan

Reputation: 15571

See http://dev.jquery.com/ticket/167 for this bug and the resolution. I am just learning jQuery. The resolution in the page I am referring ask us to use $("#method-download").get(0).checked = true; instead.

Upvotes: 0

Related Questions