Come rendere un intero Div cliccabile con jQuery
1. HTML – Creo un box con un link al suo interno
[html]
<div class="box">
<p>Lorem ipsum dolor sit amet.</p>
<p><a href="http://www.1604lab.com">Link</a></p>
</div>[/html]
2. jQuery – Aggiungo la funzione che trova il link all’intenro del box, e lo assegna alla finestra del browser
[js]
$(".box").click(function(){
window.location=$(this).find("a").attr("href");
return false;
});
[/js]
3. CSS – Aggiungo il cursore “pointer” puntatore sull’hover, per far capire all’utente che tutto il box è cliccabile.
[css]
.box:hover { cursor: pointer;}
[/css]