How do I get a value of a <span> using jQuery?

Felipe Barreiros picture Felipe Barreiros · Dec 17, 2009 · Viewed 423.1k times · Source

This is basic.

How do I get the value 'This is my name' of the above span?

<div id='item1'>
<span>This is my name</span>
</div>

Answer

Lewis picture Lewis · Dec 17, 2009

I think this should be a simple example:

$('#item1 span').text();

or

$('#item1 span').html();