Why is my onchange function called twice when using .focus()?

前端 未结 6 2090
执念已碎
执念已碎 2021-01-20 09:32

TLDR

  • Check this example in chrome.
  • Type someting and press tab. see one new box appear
  • type something and pr
6条回答
  •  Happy的楠姐
    2021-01-20 10:22

    Try this example:

    var curNum = 1;
    function myOnChange( context )
    {
        curNum++;
    
        $('').insertAfter( context );
        $('#prefix_'+ curNum ).focus();
    
        return false;
    }
    

    jsFiddle.

提交回复
热议问题