wrap
English[r?p] US[r?p]
vt. Wrap; ?(?? ?, ?? ?)... , ??, ???; vi. ??, ??(?? over, around ?? ???); ???(? ?);
jquery ?() ??? ???
??: wrap() ???? ??? ? ??? ??? HTML ??? ?? ??? ?????.
??: ??$(selector).wrap(wrapper)
????:
Parameters | Description |
wrapper | ?????. ??? ??? ???? ???? ?????. ??? ?: HTML ?? - ?: ("<div></div>") ? ?? - ?: (document.createElement("div")) ?? ?? - ?: ($(".div1")) ???? ?? ??? ?? ???? ?? ? ?????. |
??? ???? ?? ???: ??? ???? ??? ? ??? ??? ???? ?????.
??: ??$(selector).wrap(function())
????:
???? | Description |
function() | ?????. ??? ??? ???? ??? ?????. |
jquery ?() ??? ?
<html> <head> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".btn1").click(function(){ $("p").wrap("<div></div>"); }); }); </script> <style type="text/css"> div{background-color:yellow;} </style> </head> <body> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <button class="btn1">用 div 包裹每個(gè)段落</button> </body> </html>
??? ????? ??? "???? ??" ??? ?????