jQuery focus without scroll

前端 未结 7 2214
时光取名叫无心
时光取名叫无心 2020-12-08 13:48

How can I focus to a HTML element (ex. \"a\") and do not change the current scroll settings.

For ex. if I use:

$(\'#link\').focus();
<
7条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 14:11

    $('#link').css('position', 'fixed').focus().css('position', 'static') works in Firefox.

    (Edit: You should not use this hack)

提交回复
热议问题