I have a really simple question but it's something I have not done before. I have the following:
<td id="abc" style="width:15px;"><span></span></td>
I would like to put some text into the span.
How can I do this with jQuery. I know how to change things with the id of abc but not the code inside the span.
thanks,
This question is related to
jquery
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').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.
Try this
$("#abc").html('<span class = "xyz"> SAMPLE TEXT</span>');
Handle all the css relevant to that span within xyz
Syntax:
$(selector).text()
content
: $(selector).text(content)
$(selector).text(function(index, curContent))
$('#abc span').html('A new text for the span.');
Source: Stackoverflow.com