Making a clickable text or image is easy, just add the <a> tag surrounding it. But this doesn’t work with divs and sometimes we need a whole div to be clickable and not just text.
The following code is for JQuery but switching it to your favorite JS framework should be very easy.
First start by adding this to your div
<div class="clickable">
</div>
Now a little css to simulate the pointer on that div
.clickable:hover{ cursor:pointer; }
Now onto the JavaScript part
<script type="text/javascript">
$(document).ready(function()
{
$("div.clickable").click(
function()
{
window.location = $(this).attr("url");
return false;
});
});
</script>
You can use as many clickable divs as you want.