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.
See result below.
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.
No comments:
Post a Comment