I am completely stuck on this problem (see jsfiddle here). I have a very simple set up where an onclick
adds a class which displays an element. Within this element is a close button for which the onclick
should remove the class from the parent. But this is not working.
I have tried removeAttr('class')
which also fails. Looking in chrome inspector I can see the selector
is right and is targeting the parent, but the class cannot be removed.
This is part of a larger project so I cannot change the html structure. But welcome any suggestions on how to do this in jQuery.
HTML:
<div class="print-wrap">
<ul>
<li class="settings-tab">+</i>
<div class="settings-wrap">
<div class="iphone-close">x</div>
<div class="content"></div>
</div>
</li>
<li class="img">
<img src="http://placehold.it/250x166">
</li>
</ul>
</div>
jQuery:
jQuery(function(){
jQuery('.settings-tab').click(function(){
var $this = jQuery(this);
$this.addClass('settings-out');
});
jQuery('.settings-wrap .iphone-close').click(function(e){
var $this = jQuery(this);
var $parent = $this.parent('.settings-wrap').parent('.settings-tab');
$parent.removeClass('settings-out');
});
});