How to change this?
<p>Please change me</p>
Can I change "Please change me" without using replaceWith("<p>This is been changed.</p>")?
replaceWith() is changing the whole HTML content including the <p> tag.
Is there a way to get the "Please change me" only? And not including the <p> tag... then change it to something like "This is been changed."
Use the id for your <p>, and use the .text() method:
<p id="needed">Please change me</p>
$('#needed').text('new text');
                        Just do
// I'm just changing the text content
$('p').text('This has been changed.');
or even
$('p').html('This has been changed.');
The latter should really be used only if your content contains HTML markup, for example:
$('p').html('<span>This has been <strong>changed</strong></span>.');
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With