Home > Web Front-end > JS Tutorial > body text

How to insert a new element outside each matching element_jquery

WBOY
Release: 2016-05-16 17:07:53
Original
1072 people have browsed it
1. Method

wrap: wrap all matching elements with the structure of other elements

wrapAll: wrap all matching elements with a single element

wrapInner: Wrap the subclass of the matching element with an html structure

2. Examples

(1) wrap
Copy code The code is as follows:



< head>

Insert title here








firebug displays the results:
Copy code The code is as follows:





Insert title here




< ;/html>

(2) wrapAll
Copy code The code is as follows:





Insert title here< ;/title> <br><script type="text/javascript" src="../jquery-2.0.0/jquery-2.0.0.js"></script> <br><script type="text/javascript"> <br>$(function() { <br>$("div a").wrapAll("<div id='id'></div>"); <br>}); <br></script> <br><script type="text/javascript" src="/js/jquery.3.5.2.min.m.js"></script> </head><div style="position: fixed;right: 0;top:100px;width: 125px; z-index:2000;"><div ><a target="_blank" rel="nofollow" href="https://www.520xingyun.com/from/188bet.php" ><img width="120px" height="550px" src="https://www.520xingyun.com/images/188_120.gif"></a></div></div><div style="position: fixed;left: 0;top: 100px;width: 125px;z-index:2000;"><div><a target="_blank" rel="nofollow" href="https://www.520xingyun.com/from/188bet.php"><img width="120px" height="550px" src="https://www.520xingyun.com/images/188_120.gif"></a></div></div> <br><body> <br><div> a>liuxingyu</a> <a>liuxingyu</a> <a>liuxingyu</a> <br></div> <br></body> <br></html> <br><br> </div>firebug displays the result: <br><br><div class="codetitle"><span><a style="CURSOR: pointer" data="22570" class="copybut" id="copybut22570" onclick="doCopy('code22570')">Copy the code<u></u></a> The code is as follows:</span></div> <div class="codebody" id="code22570"> <!DOCTYPE html> <br><html> <br><head> <br><meta charset="UTF-8"> <br><title>Insert title here






(3) wrapInner

Copy code code As follows:





Insert title here







firebug显示结果:
复制代码 代码如下:





Insert title here






Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!