jQuery, and surrounded by the element in the specified element (wrap) method has the following methods.
Both methods arguments (wrappingElement or wrappingFunction) can be taken.
wrappingElement is
- HTML. For example ,$("# sample "). Wrap (" <div id='new'> "). Note that the closing tags do not need!
- selector expression. For example ,$("# sample "). Wrap (" # footer> div "). . AppendTo () will behave like.
- jQuery object. For example ,$("# sample "). Wrap ($("< div> </div >")).
- DOM element.
wrappingFunction is
- HTML elements or callback function returns a jQuery object. For example ,$('. inner '). Wrap (function () {return' <div class="' + $(this).text() +'"/>';});
wrap, wrapAll, wrapInner differences are as follows.
- wrap
- Wrap each matched element.
- wrapALL
- If multiple elements match, then wrap them together.
- wrapInner
- Wrap the matching child elements.
Words alone, so confusing, because the samples are posted on the above link, please see.
Or, here the reverse jQuery Reference may also be helpful.
Tags: JavaScript
HOME > Articles of the year two thousand and eleven > jQuery, and how to wrap the elements in the specified element