Here’s what i have:
jQuery.fn.convertInputType = function(t){
var e = this;
e.each(function(i){
var o = jQuery(this)
, c = o.clone();
c.attr('type',t);
o.replaceWith(c);
});
return e;
}
I can’t figure out what to return back out to make it chain, like:
$('.example').convertInputType('password').css('background','blue');
I thought i could build an array like newReturnObj[i] = o.replaceWith(c) or newReturnObj[i] = c or newReturnObj[i] = jQuery(c), but none work.
Here, this works:
Live demo: http://jsfiddle.net/qTqQr/1/