jQuery动态地关注第一个INPUT或Textarea [英] jQuery Dynamically focus on the first INPUT or Textarea

查看:97
本文介绍了jQuery动态地关注第一个INPUT或Textarea的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个棘手的早晨.

我有一系列图标.当您单击图标时,它将加载一个表单.一些表格具有输入[文本],另一些表格具有文本区域.

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.

我要提出的是jQuery,一旦我加载窗体,我就可以运行它……将焦点集中在第一个输入或textarea上,无论它是什么,它都是动态的,因此我不需要if块

What I'm trying to come up with is jQuery that once I load the form I can run that will... Focus in on the first input or textarea whatever it may be, dynamically so I don't need if blocks.

想法?

推荐答案

我认为应该这样做

$("#formId input:text, #formId textarea").first().focus();

这篇关于jQuery动态地关注第一个INPUT或Textarea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆