Get text inside span tag using jQuery

The text of a span tag can be retrieved in jQuery using the 'text' function, here's an example:


<span id='year'>2014</span>


var year = $('#year').text();

Year will be defined as '2014'.

Sign Up
comments powered by Disqus

Popular Tags

Need a web developer?

If you'd like to work with code synthesis on your next project get in touch via the contact page.