Reputation: 12276
I have a page with a JS code that selects an input's content with jQuery's $element.select()
on mouse over of the input's parent.
I want to prevent the browser scrolling the input into view when it gets selected (and also gets focus I think?) it's out of sight, because the page is an array of thumbnails with the input below each one and what this does is a chain reaction that scrolls all the way to the bottom of the page, if you don't move the mouse away.
Upvotes: 0
Views: 61
Reputation: 1743
Try this code
$('#childInput').on('focus',function(e)
{
e.preventDefault();
});
$('#parentDiv').on('mouseover',function()
{
var temp= $('body').scrollTop();
var temp1=$('body').scrollLeft();
$('#childInput').select();
$('body').scrollTop(temp);
$('body').scrollLeft(temp1);
});
Upvotes: 1