<div id="div1">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
</div>
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
</div>
<input type="button" οnclick="delete()">
js:
function delete(){
var childList = document.getElementById('div1').childNodes;
document.getElementById('div1').removeChild(childList[i]);
var childList = document.getElementById('div1').childNodes;
document.getElementById('div1').removeChild(childList[i]);
}
jquery删除最后一个元素
$("#div1 p:last").remove();
删除第i-1个p标签