Open Link in New Window onClick by Class

Comes in handy if you’re adding links to multiple external sources or components, such as locations, company websites, or PDFs.

jQuery('.google_map').on('click', function(e){ 
    e.preventDefault(); 
    var url = jQuery(this).attr('href'); 
    window.open(url, '_blank');
});

Source.

Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.