For putting p string into div we can use jquery’s wrap() function like this:
$('p').wrap("<div></div>");
Is there a way to enclose every occurrence of the string ‘p’ in a html tag?
<html>
<head>
</head>
<body>
bla bla bla Hello world other words and etc and again Hello world
</body>
</html>
In this html document there are two “Hello world”, how can I put they in p tag?
The needed html result must be:
bla bla bla `<p>Hello world</p>` other words and etc and again `<p>Hello world</p>`
With your example.. you can do it like this using regex
FIDDLE
Or using split
FIDDLE