in
I have a document with the following structure:
This is some text.
Try this, sure you will get your result.
$("#notice p").text(function(i, text) {
return text.replace("some", "My");
});
You need to target the p
tag inside the #notice
:
$("#notice p").text(function(i, text) {
return text.replace("some", "My");
});
Update 2020-03
This same logic can now be made even simpler by using an arrow function:
$('#notice p').text((i, t) => t.replace('some', 'My'));
This will work in any browser except Internet Explorer.