Possible Duplicate:
How to get all of the IDs with jQuery?
How can i get array of values attribute ID inside "span id='enable'" if i use JQuery?
<span id='enable'>
<p id='105'>English</p>
<p id='250'>Spanish</p>
<p id='56'>German</p>
</span>
<span id='disable'>
<p id='38'>BlaBla</p>
<p id='46'>BlaBla2</p>
<p id='87'>BlaBla3</p>
</span>
You can use Jquery's map
function. This will return array of "English","Spanish" and "German".
var myArray = $('#enable p').map(function(){
return $(this).text();
}).get();
For getting Id's list you can do this
var myArray = $('#enable p').map(function(){
return this.id;
}).get();
See jsfiddle http://jsfiddle.net/B3LuE/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With