是否可以在这样的一次通话中检查input[type="text"]
和textarea
中的焦点?
$("input[type='text']").focus(function() {});
或者我是否必须创建两个JQuery调用来检查两种类型的焦点?
$("input[type='text']").focus(function() {});
$("textarea']").focus(function() {});
由于
答案 0 :(得分:3)
是的,您可以使用逗号,这意味着OR
。试试这个:
$("input[type='text'], textarea").focus(function() {});
答案 1 :(得分:1)
你的意思是:
$("input[type='text'], textarea").focus(function() {});
答案 2 :(得分:0)
在jQuery中,您可以组合选择器并附加单个函数,如此
$("input[type=text],textarea").focus(function() {});