jQuery Dynamically focus on the first INPUT or Textarea

后端 未结 9 1431
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-29 04:11

Here\'s a tricky one to start the morning.

I have a series of icons. When you click an icon it loads a form. Some of the forms have input[text] others have textareas

9条回答
  •  一个人的身影
    2020-12-29 04:14

    some of your code would be nice.. but this should be easy.

    assuming your loading your for into a div that you know the id of....

    all you have to do is something like

    $('#TheIdOfYourFormDiv').find('input, textarea').first().focus()
    

    after you've loaded your form

提交回复
热议问题