Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
字符串jQuery的对象数组_Jquery_Arrays_Object - Fatal编程技术网

字符串jQuery的对象数组

字符串jQuery的对象数组,jquery,arrays,object,Jquery,Arrays,Object,在jQuery中是否有一个较短的符号来执行以下代码? 我想记录所有段落的html内容 var array = $('p').get(); $.each(array, function(i, val) { console.log(val); }); 你可以试试 console.log(array.join('')) 试试这个 $.each(($('p').get()), function(i, val) { console.log(val); }); 您可以链接您的代码:

在jQuery中是否有一个较短的符号来执行以下代码? 我想记录所有段落的html内容

var array = $('p').get();
$.each(array, function(i, val)
{
    console.log(val);
});
你可以试试

console.log(array.join(''))
试试这个

 $.each(($('p').get()), function(i, val)
{
    console.log(val);
});

您可以链接您的代码:

$('p').each(function (){
    console.log($(this).html());
});

根据您期望的格式,您可以尝试:

array.toSTring()

这将导致数组元素以“,”分隔。

您可以直接执行以下操作:

console.log($('p').get());

是否要获取段落的内容

console.log($('p').text())
try map()


将引用实际的HTMLElement。您将需要使用
this.innerHTML
而不是
this.html()
。编辑我的答案以使用JQuery的
this
@faiahime如果有帮助,我很高兴D别忘了接受答案。您希望在控制台中显示哪些信息
 var pArray=$('p').map(function() {
  return this.id;
}).get();
console.log(pArray);