扫码关注官方订阅号
$("from") 之后如何向下查找 表单里面的input
$("from :input")这样可以找,但是我的页面有多个form 表单,判断用户选择了哪个表单之后提交的时候判断当前表单的内容是否可以提交, 怎么做?
<form action="" onsubmit="checkForm(this)"> <input type="text" name="input1"> <input type="text" name="input2"> <input type="text" name="input3"> <input type="submit" value="提交"> </form> function checkForm(targetForm){ var success = false; $(targetForm).find(":input[type='text']").each(function(){ //do something }); return success; }
直接给你的input设置一个name属性,然后直接使用$('input[name=username]')即可获取那个input了
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
直接给你的input设置一个name属性,然后直接使用$('input[name=username]')即可获取那个input了