get the value of the jQuery child element

advertisements

I have the following:

<div id="knowledgeDomain" data-name="Page Field: Knowledge Domain">
<span title="Learning & Development">Learning & Development</span>
</div>

How do I get the "Learning & Development" text using jQuery? Not the title...

Thanks!!!


 $('div#knowledgeDomain').children('span').text();

This will grab the text within the child span of #knowledgeDomain.

Here's a more full code example

 <script>
 $(document).ready(function(){
     var results = $('div#knowledgeDomain').children('span').text();
     alert(results);
 });
 </script>

And here's the corresponding html

 <div id="knowledgeDomain" data-name="Page Field: Knowledge Domain">
     <span title="Learning & Development">Learning & Development</span>
 </div>