Use the textContent property to change the text of a span element, e.g. span. textContent = 'Replacement text' . The textContent property will set the text of the span to the provided string, replacing any of the existing content.
The span tag is just like a div, which is used to group similar content so it can all be styled together.
$('#abc span').text('baa baa black sheep');
$('#abc span').html('baa baa <strong>black sheep</strong>');
text()
if just text content. html()
if it contains, well, html content.
This will be used to change the Html content inside the span
$('#abc span').html('goes inside the span');
if you want to change the text inside the span, you can use:
$('#abc span').text('goes inside the span');
$('#abc span').html('A new text for the span.');
Try this
$("#abc").html('<span class = "xyz"> SAMPLE TEXT</span>');
Handle all the css relevant to that span within xyz
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