Open link on mouseover using jQuery

In today's short post, you will see how to open a link in new window on mouseover or when user takes the mouse on the link. All you need to do is to replace the click event with mousever event.

Below jQuery code assign mouseover event to all the element which have ".hoveropen" as css class. Also note, this jQuery code refers to jQuery 1.7 or higher version.
$(document).ready(function() {
    $('.hoveropen').mouseover(function(e) {
        $(this).target = "_blank";
        window.open($(this).prop('href'));      
    })  
})​
If your jQuery version is less than 1.7, then instead of "prop()", use "attr()". As "prop()" only works with jQuery 1.7+ versions.

See result below.


See Complete Code
Feel free to contact me for any help related to jQuery, I will gladly help you.
SHARE

Nothing shocks me, I'm a Software Engineer. And I am not young enough to know everything. I live in World Wide Web and from there take care of this website. This website communicates about my work, learning and experience. I believe life is short, and it is for loving, sharing, learning and connecting. So lets connect..