jquery选择器建议 [英] jquery selector suggestion

查看:104
本文介绍了jquery选择器建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i想删除第一个jcrop-holder类的所有div标签,除了图像标签

 <   p  >  
< div < span class =code-attribute> class = jcrop-holder >
< div < span class =code-keyword>> < / div >
< div > < / div >
< img < span class =code-attribute> src = img.png / >
< / div >

< div class = jcrop-holder >
< div > < / d iv >
< div > < / div >
< / div >
< / p >





预期输出< br $>
===============

 <   p  >  
< ; div class < span class =code-keyword> = jcrop-holde r >
< img src = img.png / < span class =code-keyword>>
< / div >

< div class = jcrop-holder >
< ; div > < / div >
< div > < / div >
< / div >
< / p >





i使用了这个,但我得不到结果 - >>



$(。jcrop-holder:first)。not(img)。 remove();



提前感谢

解决方案

(。jcrop-holder:first) .not(img)。remove();



提前感谢


试试以下代码



 


' div.jcrop-holder:first')。find(' div')。remove();


hello all ,

i want to remove all div tag of first jcrop-holder class except image tag

<p>
<div class="jcrop-holder">
<div></div>
<div></div>
<img src="img.png" />
</div>

<div class="jcrop-holder">
<div></div>
<div></div>
</div>
</p>



expected output
===============

<p>
<div class="jcrop-holder">
<img src="img.png" />
</div>
 
<div class="jcrop-holder">
<div></div>
<div></div>
</div>
</p>



i used this one but i cant get result -->>

$(".jcrop-holder:first").not("img").remove();

thanks in advance

解决方案

(".jcrop-holder:first").not("img").remove();

thanks in advance


Try below code


('div.jcrop-holder:first').find('div').remove();


这篇关于jquery选择器建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆