How to make a whole 'div' clickable using jQuery

How can it be possible to make a whole 'div' clickable?

<div class="clickable" url="">

In this case, you can use the following jQuery script to redirect users to the url specified when clicking the 'div' area: 

window.location = $(this).attr("url");
return false;
// Source:

Here, return false is used to avoid an event bubbling. Some recommend to use event.preventDefault() rather than return false. Please refer to  here for more about event.preventDefault() and return false.

If you want to specify the url directly within the jQuery script, please use the following:

window.location = '';

Leave a Comment