Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 818
Abs Avatar asked Jun 01 '26 18:06

Abs


1 Answers

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".

like image 153
Pointy Avatar answered Jun 04 '26 08:06

Pointy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!