A simple Big Click function

The following function is useful when we wish to make a certain area clickable. This takes in the first link, and makes the entire area clickable. This code has support for normal links as well as external links.

Necessary JS:

function cw_bigclick(){
    if($('.cw-bigclick .bigitem').length){
        $('.cw-bigclick .bigitem').on('click', function() {
            if ($(this).find('a').length > 0) {
                if($(this).find('a').attr('target')=='_blank'){
                    window.open($(this).find('a').attr('href'));
                }else{
                    window.location.href= $(this).find('a').attr('href');
                }
                return false;
            }
        });
    }
}

Expected HTML

<div class=”cw-bigclick”>
<div class=”bigitem”>
<a href=”#”></a>
</div>
<div class=”bigitem”>
<a href=”#” target=”_blank”></a>
</div>
</div>