如果容器拥有某个类的div,则从容器中删除imgs
我有divs的div。但是,这些div中的一些也有一个跨度作为div中的第一个元素。此跨度表示此div中imgs的“标签”。
我有一个脚本,如果我按住alt并点击这个“数据包”div,它将被删除。但是,我不想删除其中包含标签的数据包。对于那些,只需删除内部的imgs就足够了。
我一直无法建立这种逻辑。同样,为了通过单击并按住alt键来传达删除功能,我尝试将css属性更改为某些颜色作为提示。这也是行不通的。
$(".Card_Packet").click(function (e) {
if (e.altKey) {
$(this).live('hover', function(event) {
if (event.type === 'mouseover') {
$(this).css({
'border-color': 'red'
});
}
else {
$(this).css({
'border-color':'black'
});
}
});
if ($(this).find('Sect_Header')) { //if the div contains the label, remove only the images. Otherwise, remove the whole thing.
$(this).remove('img');
} else {
$(this).remove();
}
}
});
我确信它与我的操作顺序有关。
没有找到相关结果
已邀请:
3 个回复
俯乡骚钵皆
冲汉
小提琴:http://jsfiddle.net/maniator/xwmwD/
缔恃钨