jQuery:如何找到不包括按钮的第一个可见输入/选择/文本区域? [英] jQuery: how to find first visible input/select/textarea excluding buttons?
本文介绍了jQuery:如何找到不包括按钮的第一个可见输入/选择/文本区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试过了
$(":input:not(input[type=button],input[type=submit],button):visible:first")
但它没有找到任何东西.
but it doesn't find anything.
我的错误是什么?
UPD:我在 $(document).load() 上执行此操作
UPD: I execute this on $(document).load()
<script type="text/javascript">
$(window).load(function () {
var aspForm = $("form#aspnetForm");
var firstInput = $(":input:not(input[type=button],input[type=submit],button):visible:first", aspForm);
firstInput.focus();
});
</script>
在调试中我可以看到 firstInput 是空的.
and in the debug I can see that firstInput is empty.
UPD2:我在 Sharepoint 下运行的 ASP.NET 页面中.
UPD2: I'm in ASP.NET page running under Sharepoint.
到目前为止,我发现对于某些元素,它确实找到了它们(对于固定元素),而对于某些元素则没有.:(
I've found so far that for some elements it does find them (for fixed ones) and for some don't. :(
推荐答案
为什么不只针对您想要的目标 (demo)?
Why not just target the ones you want (demo)?
$('form').find('input[type=text],textarea,select').filter(':visible:first');
编辑
或者使用 jQuery :input 选择器过滤表单后代.
Or use jQuery :input selector to filter form descendants.
$('form').find('*').filter(':input:visible:first');
这篇关于jQuery:如何找到不包括按钮的第一个可见输入/选择/文本区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文