How to make a link by clicking on a div

4

I forgot how to make links with jQuery that execute when clicking on a div. The link I needed was with target blank.

I found this from here but I did not understand the code and could not use it.

jquery('a[href="http://site.com"]').attr('target', '_blank'); 
    
asked by anonymous 04.05.2014 / 00:28

1 answer

4

To open in a new window use window.open (as bfavaretto warned):

$('#minhadiv').click(function(){
    window.open('http://www.google.com');
});

To open in the same window use window.location :

$('#minhadiv').click(function(){
    window.location='www.google.com';
});

Example: link

    
04.05.2014 / 00:42