javascript - Getting parent class of a div when the div is rendered -


i have:

<div class="foo">  <div class="bar">  </div></div> 

when "bar" rendered, i'd check if "bar" in "foo", , if so, class name is.

what not working:

<div class="foo">  <div class="bar">   <script type="text/javascript">     $(this).load(function(){       var parentclass= $(this).parent().attr('class');      });   </script>  </div></div> 

if "bar" in "foo", want hide "bar", if not, display it, would:

if(parentclass.indexof('foo') > -1) $(this).hide(); 

if "bar" in "foo", want hide "bar":

just target child .bar of .foo ?

$('.foo .bar').hide(); 

Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -