+ 1
How to call Toggle function of different div on different button with onclick Event.
I have to make Toggle function only one. Now, this function will Toggle my different kind of div eg 4-5 div. I have given specific id to div. On each button click, I have to call Toggle function for particular single div. How can I do it when all div are display:none;
2 odpowiedzi
+ 5
It would be easier with jquery. You can have each button placed below their respective div. All buttons have same class. In this case it is .btn.
Every time you click on .btn its previous child(its respective div) will be toggled.
If it is hard to understand DM me.
0
If you can use jQuery see the last div this
https://code.sololearn.com/Wm41GW5Ru10A/?ref=app.
With css
Do it using
element1:hover > element2 {
display:block;
}
Where element2 is child of element1.
Using js
make a css for class toggler
.Googler{
display:block;
}
element 1.addEventListener("click" ()=>{
element2.classList.add("toogler");
});
Make sure your element2 which has to be toggled displayed none by css.