<div id="pastraipos">
<p>is simply dummy text of the printing and typesetting industry. </p>
<p>it is a long established fact that a reader will be distracted.</p>
<p>There are many variations of passages of Lorem Ipsum available.</p>
<p>is simply dummy text of the printing and typesetting industry. </p>
<p>is simply dummy text of the printing and typesetting industry. </p>
<p>is simply dummy text of the printing and typesetting industry. </p>
<p>is simply dummy text of the printing and typesetting industry. </p>
<p>is simply dummy text of the printing and typesetting industry. </p>
<p>is simply dummy text of the printing and typesetting industry. </p>
<p>is simply dummy text of the printing and typesetting industry. </p>
<p>is simply dummy text of the printing and typesetting industry. </p>
<p>is simply dummy text of the printing and typesetting industry. </p>
</div>
所以我理解我需要事件,并循环该事件监听器,所以我可以对所有段落产生相同的效果。
var lala = document.getElementById('pastraipos');
var lala1 = lala.childElementCount;
function F2(){
for (i = 0; i < lala1; i++){
var cln = lala.children[i].cloneNode(true);
lala.appendChild(cln)[i+1];
}
}
for (var k = 0; k < lala1; k++) {
lala.children[k].addEventListener('click', F2, false);
}
它使所有段落加倍的问题,并且无法弄清楚段落中有1000个元素(空间计数),感谢您的帮助!