Reputation: 1948
I'm coding a plugin for jQuery which now works fine on every browser but IE. This is part of the code:
(function( $ ){
$.fn.myPlugin = function(options) {
var methods = {
getFirstList: function(el){
return $("ul:first", el);
}
};
return this.each(function(){
...
var list = methods.getFirstList(this);
// "this" here refers to window or document in IE.
...
});
};
})( jQuery );
When I call the plugin ($("#myObject").myPlugin();
), the keyword "this" is not refered to the DOM object, but to the window or document.
How do I fix this?
Upvotes: 3
Views: 89