jQuery實現節點克隆

爲了便於在DOM節點進行添加或者刪除節點元素,使用克隆的方法比較方便,下面是js部分的主要代碼html

var container = $('.recordCon');
var cloneDom = container.find('.has-menus').first().clone();
container.empty();
for (var i = 0; i < 3; i++) {
	var itclone = cloneDom.clone();
	itclone.find('.userName').text('張三');
	itclone.find('.xsConInfo').text('評論信息'+i);
	itclone.find('.times').text('2019-4-15 00:00:00');
	itclone.show();
	container.append(itclone);
}
相關文章
相關標籤/搜索