Daniel J F
Daniel J F

Reputation: 1064

this.each and IE6-7

I've wrote a jQuery plugin for a project and it works perfectly in all browsers but IE6-7.

I found the problem, it's in this line:

return this.each(function(index) {  my_code  })

.each doesn't work in IE6-7 properly. This bug was fixed in the latest jQuery versions but I stack with 1.4.2 and can't update it. How can I rewrite it? Apparently I can't do this

return for ( var index=0; i<this.length; i++ ) {

or this

for ( var index=0; i<this.length; i++ ) { return

but there should be some way around.

Upvotes: 3

Views: 149

Answers (2)

MikeM
MikeM

Reputation: 27405

You identified the current jQuery fixed IE 6-7 issues. How about rewriting the jQuery.each function in your own script

http://jsfiddle.net/pxfunc/7q94J/

jQuery.extend({
    each: [1.6.2 each function here]
});

Upvotes: 3

automagic
automagic

Reputation: 1077

Something like:

var l = this.length;
var i = 0;
var results = []
for(i=0; i<l; i++){
   results.push( ... )
}

return results;

Upvotes: 0

Related Questions