I have some code, the p.words is hidden, I tried to make a judge, if next div has span tag, then show the p.words, else keep the css rule.
I use jquery.next and jquery.find to make a judge $(this).parent().next('.col').find('span'), but it will show all the p.words even the next div has no span tag
<style>
.words{display:none;}
</style>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
$('.words').each(function(){
if($(this).parent().next('.col').find('span')){
$(this).css('display','block');
}
});
});
</script>
<a>Voodoo
<p class="words"> 1</p><!-- do not show -->
</a>
<div class="col">
<ul>
<li>ATI Rage128 Pro</li><!-- no span tag -->
</ul>
</div>
<a>NVIDIA
<p class="words"> GeForce2 MX</p><!-- show -->
</a>
<div class="col">
<ul>
<li>
<span>NVIDIA GeForce2 MX 400</span><!-- have span tag -->
</li>
<li>
<span>ATI 9200SE</span>
</li>
</ul>
</div>
Change
to
The result of
$(this).parent().next('.col').find('span')is an array which may or may not be empty, but will always resolve totruein your condition.