+ 2

How To make onclick css

Hello everybody. I Need help. How make onclick event on css. Situation: I made hidden div And another div named "button" I want make : if I Will click on button, hidden div after clicking change his property to visible

2nd Jan 2019, 9:25 AM
Daniil Timonov
Daniil Timonov - avatar
3 Answers
+ 5
It is actually not possible with only CSS. https://stackoverflow.com/questions/13630229/can-i-have-an-onclick-effect-in-css But with help of JavaScript or jQuery, you can surely do that. code is given by Š˜Š³Š¾Ń€ŃŒ ŠÆŠŗŠ¾Š²ŠµŠ½ŠŗŠ¾ In css you can use active property, but it is not exactly onclick. https://www.w3schools.com/cssref/sel_active.asp
2nd Jan 2019, 9:44 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 3
You could use only css pseudo element :target to achieve it. https://code.sololearn.com/WZC8i1RxoeOH/?ref=app
2nd Jan 2019, 10:07 AM
CalviÕ²
CalviÕ² - avatar
0
HTML: <div id="div1"> .... </div> <div onclick=f()> .... </div> JS: function f(){ document.getElementById("div1").style.property=value; } "property" - the name of the property, "value" - the value of the property
2nd Jan 2019, 9:46 AM
Š˜Š³Š¾Ń€ŃŒ ŠÆŠŗŠ¾Š²ŠµŠ½ŠŗŠ¾
Š˜Š³Š¾Ń€ŃŒ ŠÆŠŗŠ¾Š²ŠµŠ½ŠŗŠ¾ - avatar