$("#keyword-content").html()
Produces
<p>
javascript
</p>
<p>
ruby
</p>
<p>
python
</p>
How can I convert this to ["javascript", "ruby", python"] ?
You can use the map method:
var arr = $('#keyword-content p').map(function(){
return $(this).text()
}).get()
Something like this:
var myArray = [];
$("#keyword-content p").each(function(index,item) {
myArray.push($(item).text());
});
#<HTMLParagraphElement> has no method 'text'. I tried something similar with underscore.js before I came to SO for help.