开发者

change focus into particular div

开发者 https://www.devze.com 2023-01-17 02:16 出处:网络
how can i change focus into p开发者_运维技巧articular div after any event via jquery?To make a div focusable, it needs to have a tabindex attribute.

how can i change focus into p开发者_运维技巧articular div after any event via jquery?


To make a div focusable, it needs to have a tabindex attribute.

<div id='test' tabindex='1'></div>

Then, you can focus with e.g.

$('#something').click(function() {
  $('#test').focus();
});


Use $(window).scrollTop() It'll scroll the window to the particular item.

Here is the example

 var scrollPos =  $(".focusme").offset().top;
 $(window).scrollTop(scrollPos);
0

精彩评论

暂无评论...
验证码 换一张
取 消