Multiple selector chaining in jQuery?
Solution 1:
You can combine multiple selectors with a comma:
$('#Create .myClass,#Edit .myClass').plugin({options here});
Or if you're going to have a bunch of them, you could add a class to all your form elements and then search within that class. This doesn't get you the supposed speed savings of restricting the search, but I honestly wouldn't worry too much about that if I were you. Browsers do a lot of fancy things to optimize common operations behind your back -- the simple class selector might be faster.
Solution 2:
$("#Create").find(".myClass").add("#Edit .myClass").plugin({});
Use $.fn.add
to concatenate two sets.
Solution 3:
You should be able to use:
$('#Edit.myClass, #Create.myClass').plugin({options here});
jQuery | Multiple Selectors
Solution 4:
I think you might see slightly better performance by doing it this way:
$("#Create, #Edit").find(".myClass").plugin(){
// Options
});