+ 3
How to make a whole div clickable?
3 Antworten
+ 21
<div tabindex=1 onclick=…>
(its already clickable...)
+ 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;
}
+ 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