我怎样才能通过使用 Jquery 遍历这些文本框来清除它们?
<div class="col-md-4" id="RegexInsert">
<h4>New Regex Pattern</h4>
<form role="form">
<div class="form-group">
<label for="firstName">Desription</label>
<input type="text" class="form-control" id="txtRegexDesription" placeholder="Description" />
</div>
<div class="form-group">
<label for="firstName">Regex pattern</label>
<input type="text" class="form-control" id="txtRegexPattern" placeholder="Regex pattern(C#)" />
</div>
<div class="form-group">
<label for="firstName">Data type</label>
<input type="text" class="form-control" id="txtDataType" placeholder="Data type" />
</div>
<button type="button" class="btn btn-default btn-sm btnAddRegexPattern" data-applicationid=""><span class="glyphicon glyphicon-plus"></span> Add</button>
</form>
</div>
我正在做以下尚未完成的事情。
$("#RegexInsert .inputs").each(function () {
$('input').val('');
});
亲切的问候
最佳答案
你不需要循环,你可以在单个选择器中完成:
$('.form-control').val('');
我不确定您示例中的 .inputs
是从哪里来的,因为它不在您的 HTML 中。如果需要,您可以使选择器更通用:
$('#RegexInsert input[type="text"]').val('');
关于javascript - 使用jquery循环遍历文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23558323/