method of inserting new elements outside of each matching element

Source: Internet
Author: User

  This article gives you a way to insert new elements outside of each matching element, and here's a good example, and interested friends can refer to the following

Method     Wrap: Wrap all the matching elements in a structured way with other elements     Wrapall: Wrap all the matching elements together with a single element     Wrapinner: The child of the matching element Class wrapped in HTML structure     II, instance     (1) wrap  code is as follows: <! DOCTYPE html>  <html>  <head>  <meta charset= "UTF-8" >  <title>insert Title here</title>  <script type= "Text/javascript" src= ". /jquery-2.0.0/jquery-2.0.0.js "></script>  <script type=" Text/javascript ">  $ (function () {   $ ("div a"). Wrap ("<div id= ' id ' ></div>"); });  </script>  </head>  <body>  <div>  <a>liuxingyu</a> <a>liuxingyu</a> <a>liuxingyu </a> <a>liuxingyu</a>  </div>  </body>  </html>    Firebug Display Results:    code as follows: <! DOCTYPE html>  <html>  <head>  <meta charset= "UTF-8" >  <title>insert Title Here</title>  <script src= ". /jquery-2.0.0/jquery-2.0.0.js "type=" Text/javascript ">  <script type=" Text/javascript ">  </ head>  <body>  <div>  <div id= "id" >  <a>liuxingyu</a>  </div>  <div id= "id" >  <a>liuxingyu</a>  </div>  <div id= "id" >  <a>liuxingyu</a>  </div>  <div id= "id" >  <a>liuxingyu</a >  </div>  </div>  </body>  </html>    (2) wrapall  code as follows : <! DOCTYPE html>  <html>  <head>  <meta charset= "UTF-8" >  <title>insert Title here</title>  <script type= "Text/javascript" src= ". /jquery-2.0.0/jquery-2.0.0.js "></script>  <script type=" Text/javascript ">  $ (function () {   $ ("div a"). Wrapall ("<div id= ' id ' ></div>"); });  </script>  </head>  <body>  <div>  <a>liuxingyu</a> <a> liuxingyu</a> <a>liuxingyu</a> <a>liuxingyu</a>  </div>  </body >  </html>    Firebug display results:  code as follows: <! DOCTYPE html>  <html>  <head>  <meta charset= "UTF-8" >  <title>insert Title here</title>  <script src= ". /jquery-2.0.0/jquery-2.0.0.js "type=" Text/javascript ">  <script type=" Text/javascript ">  $ ( function () {  $ ("div a"). Wrapall ("<div id= ' id ' ></div>"); });  </script>  </ head>  <body>  <div>  <div id= "id" >  <a>liuxingyu</a> <a> liuxingyu</a> <a>liuxingyu</a> <a>liuxingyu</a>  </div>  </div >  </body>  </html>    (3) wrapinner  code as follows: <! DOctype html>  <html>  <head>  <meta charset= "UTF-8" >  <title>insert Title here</title>  <script src= ". /jquery-2.0.0/jquery-2.0.0.js "type=" Text/javascript ">  <script type=" Text/javascript ">  $ ( function () {  $ ("div"). Wrapinner ("<div id= ' id ' ></div>"); });  </script>  < /head>  <body>  <div>  <a>liuxingyu</a> <a>liuxingyu</a> < a>liuxingyu</a> <a>liuxingyu</a>  </div>  </body>  </html>     Firebug Display results:  code as follows: <! DOCTYPE html>  <html>  <head>  <meta charset= "UTF-8" >  <title>insert Title here</title>  <script src= ". /jquery-2.0.0/jquery-2.0.0.js "type=" Text/javascript ">  <script type=" Text/javascript ">  $ ( function () {  $ ("div"). Wrapinner ("<div id= ' id" ></dIv> "); });  </script>  </head>  <body>  <div>  <div id=" ID ">  <a>liuxingyu</a> <a>liuxingyu</a> <a>liuxingyu</a> <a> liuxingyu</a>  </div>  </div>  </body>  </html>   
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.