Find all the text nodes inside a paragraph and wrap them with an italic tag using jquery
- جي كويري
- 2021-09-17
- mhanasmh00489829403
الأجوبة
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>" );
معلومات ذات صلة