[ACCEPTED]-Hiding parent divs in Jquery-html
Accepted answer
You need to stop propagation of the click 3 event in the handler for the inner element. Without 2 that the handler for the parent will also 1 be invoked. See the jQuery event object for more info.
$("#elt").click( function (e) {
e.stopPropagation();
$(this).parent().parent().hide();
});
n/aUsed a combination of the above. Thanks 2 to both members for their answers. great 1 help.
jQuery(function ($) {
$('.coffee-strength p span').each(function () {
var string = $.trim($(this).text());
if(string!="22"){
$(this).html('<img src="/images/' + string + '.png" alt="' + string + '" />');
}else{
$(this).parent().parent().hide();
}
});
});
</script>
You can also take advantage of event propagation 1 and attach just one event:
$(function() {
$("#parent0").hide();
$("#interviewer-Button").on('click', function(e){
$(this).find('#parent0').toggle(e.target.id !== 'elt');
});
});
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.