I just want to click on the box, make him active and then on the second click do him inactive. I know that there is method with boolean but I'm not sure how to use it. Thank you for any help. Here's jsfiddle .
$(".box").click(function(){
var THIS = $(this);
$(".box").removeClass("active");
THIS.addClass("active");
});
Something like this should do the job. jQuery has a built in toggle function for things like this
$('.box').click(function(){
$(this).toggleClass('active');
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.