<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>获取内容</title>
</head>
<body>
<div id="test">
<p class="title">1111</p>
<p class="content">10101010</p>
<p class="title">222</p>
<p class="content">20202020</p>
<p class="title">333</p>
<p class="content">30303030</p>
</div>
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script>
var array = $('#test').find('p.title').map(function (index, ele) {
return ele.innerHTML;
}).get();
console.log(array);
</script>
</body>
</html>
而输出的结果为:
["1111", "222", "333"]