Getting parent class of a div when the div is rendered
I have:
<div class="foo">
<div class="bar">
</div></div>
When "bar" is rendered, I'd like to check if "bar" is in "foo", and if so,
what the class name is.
What is 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" is in "foo", I want to hide "bar", if not, display it, so I would:
if(parentClass.indexOf('foo') > -1) $(this).hide();
No comments:
Post a Comment