Home >>jQuery Tutorial >jQuery wrapInner() Method
jQuery wrapInner() method in jQuery is used to wraps specified HTML element around the content of each selected element.
Syntax:$(selector).wrapInner(wrappingElement,function(index))
Parameter | Description |
---|---|
wrappingElement | It is a required parameter and is used to Specifies what HTML element to wrap around the content
Possible values:
|
function(index) | It is optional and is used to returns the wrapping element of a function
|
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".btn1").click(function(){
$(".txt1").wrapInner("<b></b>");
});
});
</script>
</head>
<body>
<p class="txt1">This is First paragraph.</p>
<p class="txt1">This is Second paragraph.</p>
<button class="btn1">Click me to Wrap a content</button>
</body>
</html>
This is First paragraph.
This is Second paragraph.