How to remove focus from input field in jQuery?

后端 未结 5 1319
故里飘歌
故里飘歌 2020-12-23 23:54

I am setting the focus on a certain input field when loading a page using the following line:

$(\'#myInputID\').focus();

Is there a way th

5条回答
  •  半阙折子戏
    2020-12-24 00:31

    If you have readonly attribute, blur by itself would not work. Contraption below should do the job.

    $('#myInputID').removeAttr('readonly').trigger('blur').attr('readonly','readonly');
    

提交回复
热议问题