.wrapAll( wrappingElement )
<html> <head> <title>ThaiCreate.Com jQuery Tutorials</title> <style> div { border: 2px solid blue; } p { background:yellow; margin:4px; } </style> <script type="text/javascript" src="jquery-1.6.4.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p").wrapAll("<div></div>"); }); </script> </head> <body> <p>Hello</p> <p>cruel</p> <p>World</p> </body> </html>
<html> <head> <title>ThaiCreate.Com jQuery Tutorials</title> <style> div { border:2px blue solid; margin:2px; padding:2px; } p { background:yellow; margin:2px; padding:2px; } strong { color:red; } </style> <script type="text/javascript" src="jquery-1.6.4.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("span").wrapAll("<div><div><p><em><b></b></em></p></div></div>"); }); </script> </head> <body> <span>Span Text</span> <strong>What about me?</strong> <span>Another One</span> </body> </html>
<html> <head> <title>ThaiCreate.Com jQuery Tutorials</title> <style> div { border: 2px solid blue; } p { background:yellow; margin:4px; } </style> <script type="text/javascript" src="jquery-1.6.4.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p").wrapAll(document.createElement("div")); }); </script> </head> <body> <p>Hello</p> <p>cruel</p> <p>World</p> </body> </html>
<html> <head> <title>ThaiCreate.Com jQuery Tutorials</title> <style> div { border: 2px solid blue; margin:2px; padding:2px; } .doublediv { border-color:red; } p { background:yellow; margin:4px; font-size:14px; } </style> <script type="text/javascript" src="jquery-1.6.4.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p").wrapAll($(".doublediv")); }); </script> </head> <body> <p>Hello</p> <p>cruel</p> <p>World</p> <div class="doublediv"><div></div></div> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท