Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript HTML values to Array

$("#keyword-content").html()

Produces

  <p>
    javascript
  </p>
  <p>
    ruby
  </p>
  <p>
    python
  </p>

How can I convert this to ["javascript", "ruby", python"] ?

like image 310
Dru Avatar asked Apr 22 '26 13:04

Dru


1 Answers

You can use the map method:

var arr = $('#keyword-content p').map(function(){
      return $(this).text()
}).get()
like image 127
undefined Avatar answered Apr 25 '26 03:04

undefined