Usually, when I use a class as a selector, I try to use the "id" selector so that it does not view the entire page, but only the area in which the class would be.
However, I have a partial view with the code in it. This partial view (generic code) is wrapped around a form tag.
I have:
<form id="Create"> // load common code in from partial view </form> <form id="Edit"> // load common code in from partial view </form>
Now in this general code, I need to attach the plugin to several fields so that I do
$('#Create .myClass').plugin({ options here}); $('#Edit .myClass').plugin({options here});
So this is almost the same code. I am wondering if there is a way to make it look for any of the identifiers?
Edit
I am having problems with it when I have variables for my selectors
my.selectors = { A: '#Create', B: '#Edit', Plugin: ' .Plugin' }; $(selector.A+ selectors.Plugin, selector.B+ selectors.Plugin)
It doesn't seem to work.
jquery jquery-selectors
chobo2 Apr 20 2018-11-21T00: 00Z
source share