I tried
$(":input:not(input[type=button],input[type=submit],button):visible:first")
但它没有找到任何东西。
我的错误是什么?
UPD:我在 $(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 是空的。
更新2:
我在 Sharepoint 下运行的 ASP.NET 页面中。
到目前为止,我发现对于某些元素,它确实找到了它们(对于固定元素),而对于某些元素则没有。 :(
为什么不只针对您想要的目标(demo http://jsfiddle.net/VU3vg/)?
$('form').find('input[type=text],textarea,select').filter(':visible:first');
Edit
或者使用 jQuery:input https://api.jquery.com/input-selector/选择器来过滤表单后代。
$('form').find('*').filter(':input:visible:first');
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)