Can you extend the val() function in jQuery? -


is there way extend val() function in jquery.

basically, want set class variable if there content being dynamically entered input.

whick like

var thisval = 'hello world';     $('#myinput').val(thisval).addclass('dark'); 

it nice tell val() function add class 'dark' input if there value, , remove if empty.

possible?

try

$.fn.xval = function () {     return this.toggleclass(arguments.length).val.apply(this, arguments); }; 

demo: http://jsfiddle.net/mattball/v9yfu/


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -