I have a custom plugin very simple. If it returns this
after calling it, .end()
works great. However if it returns $(this)
, .end()
doesn't work. Why does that happen? Am I missing something here?
Code:
$.fn.fnBar = function() {
$(this).html("hello!");
//return $(this); // Doesn't work
return this; // Works!
};
$("div")
.find("span")
.fnBar()
.end()
.css("color", "red");