+ 3
you can do this with if else statements in javascript. el.on(‘click’, () => { if (el.style.display === “none”) el.style.display = “block”; else el.style.display = “none”; });
1st Aug 2020, 8:43 PM
Brian R
Brian R - avatar
+ 2
In a div create h1 (heading) and a p (for message). Now create a new class in css .classname{ display :none; only } On h1 add a click event function In fxn access p let's var para Then Para.classList.toggle("classname") ; Hope it will work
1st Aug 2020, 8:51 PM
Divya Mohan
Divya Mohan - avatar
+ 2
👍👍
1st Aug 2020, 9:03 PM
Divya Mohan
Divya Mohan - avatar
+ 1
Brian R if el is display none how one can click on it to make it display block??? Your click event is on the same element. does it work??
1st Aug 2020, 8:56 PM
Divya Mohan
Divya Mohan - avatar