nwrapper jQuery plug in
jQuery provides a large variety of funtions for element manipulation, that in most cases will manipulate the selected elements in no time. A very useful function for every day manipulation is the .wrap() function that we can use to wrap an HTML structure around each jQuery element. But what happens when we want to wrap an HTML structure every n’th number of the selected elements? Unfortunately, jQuery doesn’t provide any options to the warp function in order to to do something similar.
Well with nwrapper you can do just that.
How to install/use
First of all the plugin (after you load jQuery) just like this :
To use it, just select the parent element of the elements you want to wrap, choose how often you’ll apply the wrap (wrapEvery attribute – default is 1), choose if you need the default classes or even provide your own extra classes (extraClasses as an array), and finally provide the HTML structured element you’ll use for a wrapper (the default is div, but you can also use a span or any other element).
wrapEvery : 2,
defaultClasses : true,
extraClasses : ['class1', 'class2'],
htmlStructure : 'span'
Demo / Contact
MIT License (MIT)
Copyright (C) 2011 John Tsevdos