jquery : focus to div is not working

前端 未结 3 540
余生分开走
余生分开走 2020-12-01 08:57

After the ajax function is over. in success messages I\'m focusing to the specific div. But it\'s not working. My code is here.

$j.ajax({
    url:\"

        
3条回答
  •  遥遥无期
    2020-12-01 09:39

    a

    can be focused if it has a tabindex attribute. (the value can be set to -1)

    For example:

    $("#focus_point").attr("tabindex",-1).focus();
    

    In addition, consider setting outline: none !important; so it displayed without a focus rectangle.

    var element = $("#focus_point");
    element.css('outline', 'none !important')
           .attr("tabindex", -1)
           .focus();
    

提交回复
热议问题