如何在 JQuery 中的文本框中获取空值
How to get null values in textboxes in JQuery?
实际上我有一个注册表和一个设置页面。当我将页面更改为设置页面时,在注册表中输入一些值后,如果我返回注册页面,我希望以前输入的所有值都需要为空,但它们会根据我输入的值显示。
以下代码显示了我的代码的完整描述:
索引.html
<section id="main" data-role="page">
<div data-role="content" class="mainScreen">
<a href="#Registration" data-transition="slide" data-theme="e" data-role="button" data-icon="arrow-r" data-iconpos="right">Register</a>
<a href="#settings" data-transition="slide" data-theme="e" data-role="button" data-icon="arrow-r" data-iconpos="right">Settings</a>
</div>
<section id="Registration" data-role="page">
<div class = "registrationScreen">
Name <input type="text" id="name" name="name"> </input>
Age <input type="number" id="age" name="age"></input>
Mobile Number <input type="number" id="mobile" name="mobile"> </input>
Email Id <input type="email" id="email" name="email"> </input>
<input type="submit" id="register" name="register" value="Register"> </input>
</div>
</section>
<section id="settings" data-role="page">
<div data-role="content">
<p>.....</p>
</div>
</section>
当我将页面更改为设置页面时,在注册表单中输入一些值后,按照以下代码,如果我返回注册表,所有值都需要为空。谁能帮我解决这个问题...正在等待您的回复...
$(document).ready(function() {
$("input[type='text']").val(''); //sets blank to all textboxes of type input
});
或者,如果您希望清除特定div 的输入,则:
$(".registrationScreen :input:not(input[type='submit'])") { //except for submit
$(this).val('');
});
以下 jQuery 将清除作为类registrationScreen
子级的所有表单元素:
$(".registrationScreen").children().each(function() {
$(this).val("");
});
相关文章:
- 当值更改时,在servlet中自动获取textarea值,无需单击按钮
- 通过 Yii2 表单插入数据时获取空值
- 当浮点部分为空时,从 JQuery 中的输入元素获取数字值不起作用
- 获取返回空值的元素 { 绝对|相对|固定 }
- 如何在 JQuery 中的文本框中获取空值
- 我从 ascx 文件中获取空值
- 在使用 AJAX 时获取数据库的空值
- AJAX 获取向控制器发送空值的调用
- 中继:获取递归数据返回空值
- 表单提交后获取空的隐藏值
- 使用Javascript从url中获取空哈希值
- 如何在不向输出数组获取空值的情况下拆分字符串
- get(一个空字符串)时尝试在 js 中获取 marginTop 值
- 如何防止“无法获取属性值”'dir':对象为空或未定义&;在IE9中加载页面时出现错误
- 无法获取属性值'appendChild':对象为空或未定义"同时追加脚本到IE
- 不能在请求中获取TextArea值,总是空的
- JQPlot饼图抛出“无法获取属性值”'0':对象为空或未定义&;错误
- Selenium WebDriver,从DOM中获取空值
- 使用val()获取空值
- 自动填充空值在ng模型中,从ng选项获取数据