How can I override on val() method, not on all but on those ones that return by my plugin, for instance look at following sample:
(function ($) {
$.fn.switch = function (action, options) {
var settings = $.extend({
}, options);
return this.each(function () {
$this.val = function(){
return 10;
}
});
};
})(jQuery);
I expect that $("#some-id").switch().val()
returns 10
while it seems that it doesn't work.
I don't want to use $.fn.val
to override on entire objects.
How should I achieve that?
val()
behavior, Changing it for specific elements only could lead to confusion