Answer the question
In order to leave comments, you need to log in
How can I implement the appearance and hiding of a block in js or jquery?
Hello everyone, I have this script:
$('.floor,.floorcase').click(function() {
$(this).addClass('fade');
});
$(document).mouseup(function (e) {
var container = $('.floor');
if (container.has(e.target).length === 0){
container.removeClass('fade');
}
});
Answer the question
In order to leave comments, you need to log in
$('.floor').click(function() {
$('.floor, .floorcase').each(function() {
$(this).addClass('fade');
});
});
$(document).mouseup(function(e) {
const floor = $('.floor');
const floorcase = $('.floorcase');
if (floor.has(e.target).length === 0 && floorcase.has(e.target).length === 0) {
floor.removeClass('fade');
floorcase.removeClass('fade');
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question