How to make a whole div clickable? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 3

How to make a whole div clickable?

9th May 2017, 10:21 AM
Rohit Mahabare
Rohit Mahabare - avatar
3 Respuestas
+ 21
<div tabindex=1 onclick=…> (its already clickable...)
9th May 2017, 10:34 AM
Valen.H. ~
Valen.H. ~ - avatar
+ 4
both @Valentin and @Thanh is right. If you want to show click icon/pointer when mouse hover, use css. then handle the click event via javascript. div { cursor:pointer; }
9th May 2017, 11:43 AM
Apel Mahmod
Apel Mahmod - avatar
+ 3
option 1: wrap it inside an anchor tag <a>... </a> option 2: set the attribute "onclick" and assign an event handler to it option 3: apply an id and then get the div via its id by "getElementById" and set the eventhandler for the event "onclick" with the method addEventListener
9th May 2017, 10:35 AM
Thanh Le
Thanh Le - avatar