<script>
var a = document.querySelector('.secenek-1');
var b = document.querySelector('.secenek-1-kismi');
a.addEventListener("click",function(e){
e.preventDefault
b.classList.contains("showing") ? b.classList.remove("showing") : b.classList.add("showing");
})
var c = document.querySelector('.secenek-2');
var d = document.querySelector('.secenek-2-kismi');
c.addEventListener("click",function(e){
e.preventDefault
d.classList.contains("showing") ? d.classList.remove("showing") : d.classList.add("showing");
})
var e = document.querySelector('.secenek-3');
var f = document.querySelector('.secenek-3-kismi');
e.addEventListener("click",function(e){
e.preventDefault
f.classList.contains("showing") ? f.classList.remove("showing") : f.classList.add("showing");
})
</script>
I want that if .secenek-1-kismi
div is open, if i clicked secenek-2
, .secenek-1-kismi
will close and .secenek-2-kismi
will open
2
Answers
ill fix it.
To achieve the behavior you described, you’ll need to modify the event listeners. You can add conditional checks to close any open sections before opening the clicked section. Here’s the updated code: