$("#keyword-content").html()
Produces
<p>
javascript
</p>
<p>
ruby
</p>
<p>
python
</p>
我该如何将它转换为
["javascript", "ruby", python"]
?$("#keyword-content").html()
Produces
<p>
javascript
</p>
<p>
ruby
</p>
<p>
python
</p>
["javascript", "ruby", python"]
?map
方法:var arr = $('#keyword-content p').map(function(){
return $(this).text()
}).get()
类似这样:
var myArray = [];
$("#keyword-content p").each(function(index,item) {
myArray.push($(item).text());
});
#<HTMLParagraphElement>没有'text'方法
。在来到SO寻求帮助之前,我尝试过类似的underscore.js的东西。 - Dru