I have a html like this
<div class="accordion_in1 accordion_in acc_active">
<div class="acc_head" id="removeArrow">
<div class="acc_icon_expand"></div>
<a href="/Investor-Relations">Investor Relations</a>
</div>
<div class="acc_content" style="display: block;">
<div class="acc_content_faq1">
<ul>
<li>
<a href="/Profile" id="ctl00_ctl22_rep1_ctl06_rep2_ctl01_hypLevel2">Profile</a>
</li>
</ul>
</div>
<div class="acc_content_faq1">
<ul>
<li>
<a href="/Directors" id="ctl00_ctl22_rep1_ctl06_rep2_ctl02_hypLevel2">Directors</a>
</li>
</ul>
</div>
</div>
</div>
I need to remove the class acc_head
from the second div if there is no div with class acc_content
I tried to get this in jquery like
<script>
$(document).ready(function(){
if ($("accordion_in > div.acc_content").length < 0) {
$('#removeArrow').removeClass('.acc_head')
}
});
</script>
But I can't able to remove the class.Can any one help Thanks in advance for help
If there is no selector with accordion_in > div.acc_content
, the length is 0, not a value less than 0.
Try this code.
if (!$("accordion_in > div.acc_content").length) {
$('#removeArrow').removeClass('.acc_head')
}
Try this code.
if ($("accordion_in > div.acc_content").length) {
$('#removeArrow').removeClass('acc_head')
}
Try this:
<script>
$(document).ready(function(){
if (($(".acc_active").find("div.acc_content")).length == 0) {
$('#removeArrow').removeClass('.acc_head');
}
});
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.