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:

HTML

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

jQuery

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

Year will be defined as '2014'.

Sign Up
comments powered by Disqus
Sign Up

Popular Tags

350x250

Need a web developer?

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