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

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -