jquery - How to use muliple variables in same function -


what proper way combine multiple variables

i tried didn't work.

varone = "td.class1"; vartwo = "td.class2";  $('table').find(varone,vartwo).css('background', 'red'); 

well, need set selectors jquery way, example

varone = $("td.class1"); vartwo = $("td.class2");  $('table').find(varone,vartwo).css('background', 'red'); 

then script work.

you can use concatenated string

varone = "td.class1"; vartwo = "td.class2";  $('table').find(varone + "," + vartwo).css('background', 'red'); 

and work. recommend first solution cleaner, can choose.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -