JQuery selector in variable -


I want to ask about using selector from a variable

First I:

and it has been changed to

  $ ('input') (check);  

And they work fine.

But now I want to give some value in the function to make it dynamic, like

  $ ('input') change (check ('info'.) );  

and change the function to

  function check (SEL) {$ (sel + 'input,' + sel + 'select'). Each (function (n, element) {if ($ (element) .val () == '') Warning ('empty');}); }  

but it does not work any help please .. Thanks,

Negut

change should get a function by writing check ('. Info') you are triggering the function, and its results Wrap the call in another function with just passing in the change event:

  $ ('input'). Change (function () {check ('. Info');});  

Comments