How I get active class only on click div not on all div??
html code
<div class="col-12">
<div class="place" id="test-1"></div>
</div>
<div class="col-12">
<div class="place" id="test-2"></div>
</div>
<div class="col-12">
<div class="place" id="test-3"></div>
</div>
Jquery code
// adding this div for each place class
$('.place').wrap('<div.class="main__place"></div>')
//cut icon for hide
$('<i class="fa fa-x removeBtn”></i>').insertBefore(".place")
$(".removeBtn").on("click",function(){
$(".main__place").addClass("active")
})`
https://jsfiddle.net/xf9gpk2t/2/
Refer above js fiddle
whenever I click on full screen icon all div get’s active class
2
Answers
In the following snippet I remove the clicked element by "looking up" to the closest
.col-12
element:If you just want to toggle a class then you can just do that too:
Could you try this :
I have added an
x
to the remove button, you can remove it since you will have no problem with thefa
icons.