jquery wrapInner() method
Translation results:
wrap
英[ræp] 美[ræp]
vt. Wrap; wrap; wrap with... (or bandage, cover, etc.); cover
n. Lap blanket, shawl, scarf, scarf, headscarf, blouse, jacket, coat; wrapping paper;
vi. Winding, coiling (usually used in conjunction with over, around, etc.) ; Wrap up, wrap up; put on (clothes, etc.) .Internal, inner; spiritual; secret
n.Internal, inside; a shot that hits the part close to the bullseye Function: The wrapInner() method uses the specified HTML content or element to wrap all the content (inner HTML) in each selected element. Syntax: $(selector).wrapInner(wrapper) Parameters: Use functions to wrap content: Use functions to specify the content wrapped around each selected element Syntax : $(selector).wrapInner(function()) Parameters: Click the "Run instance" button to view the online instancejquery wrapInner() methodsyntax
Parameter Description wrapper Required. Specifies the content surrounding the selected element's content. Possible values: HTML code - e.g. ("<div></div>") New DOM element - e.g. (document.createElement("div")) Existing element - e.g. ($(".div1" ))Existing elements will not be moved, but will only be copied and wrapped around the selected element. ##Parameters Description function() Required. Specifies a function that returns the surrounding elements. jquery wrapInner() methodexample
<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").wrapInner("<b></b>");
});
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button class="btn1">加粗段落中的文本</button>
</body>
</html>