jQuery reducing code for better maintainability? -


In jQuery you can

  $ ("# id1, # ​​id2") You can. do something();   

But if you have

  var $ id1 = $ ("# id1"); Var $ id2 = $ ("# id2");   

Is there any way to group them together easily and execute doSomething ()?

  $ ($ id1, $ id2) .doSomething (); // error   

It's okay to have only two elements, but if I like more than 10 elements I'll need to repeat ...

  $ Id1.do (); $ Id2.doSomething (); ....   

Is it an easy way to group them?

You can use it:

  var $ allIds = $ Id1.add ($ id2); $ AllIds.doSomething ();    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -