Q:

Find all the text nodes inside a paragraph and wrap them with an italic tag using jquery

0

Find all the text nodes inside a paragraph and wrap them with an italic tag.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

HTML Code :

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-git.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Find all the text nodes inside a paragraph and wrap them with a italic tag.</title>
</head>
<body>
<p><a href="https://www.w3resource.com/jquery-exercises/">jQuery</a> Exercises, Practice and Solution</p>
<p><a href="https://www.w3resource.com/javascript-exercises/">JavaScript</a>  Exercises, Practice and Solution</p>
</body>
</html>

JavaScript Code :

$( "p" )
.contents()
.filter(function(){
return this.nodeType !== 1;
})
.wrap( "<i></i>" );

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now