Select multiple elements with complex selectors to do the same action in all.
Pass a array of selectors to the plugin function, as below:
$.eachSelector([
$('#element').find('a.test'),
'#otherElement > a',
$('input[name="test"]').parents('p')
]).css({ color : 'yellow'});
The plugin will concatenate the selectors and returns them.
To do the same thing without using this plugin, do as below:
$('.element').find('> a.test').add(
$('#otherElement > a')
).add(
$('input[name="test"]').parents('p')
).css({
color : 'red'
});
This works perfectly, but it is hard to write and understand, don't you thing?
This plugin works fine from jQuery 1.4 until the last version.
Install NodeJS, GIT if you don't have it yet, bower and grunt
npm install bower
npm install grunt-cli
1 - Clone it:
git clone [email protected]:felquis/jQueryEachSelector.git
2 - Then go to the project's folder:
cd jQueryEachSelector
3 - Install dependencies:
npm install
4 - Run:
grunt build
Maybe you'll need to use the sudo
prefix
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Use in everything you feel necessary. And do not remove the link from this repository :)