单击下一个按钮时,如果文本框为空,则控制文本框我想在文本框附近添加删除图标。我试过这个,但没有用。
$(".nextBtn").click(function () {
$(".txt").each(function () {
$currentVal = $(this).val();
if ($currentVal.length == 0 || $currentVal == $(this).attr('placeholder')) {
//$(this).css({"backgroundColor": "black", "color": "white"});
$('<a data-role="button"data-icon="delete"></a>').insertAfter($(this));
}
});
});
//jquery手机
<div data-role="content">
<div data-role="fieldcontainer">
<label for:"name">Name:</label>
<input type="text" class="txt" id="name" required placeholder="Enter your name">
</div>
<div data-role:"fieldcontainer">
<label for:"surname">Surname:</label>
<input type="text" class="txt" id="surname" required placeholder="Enter your surname">
</div>
<div data-role:"fieldcontainer">
<label for:"email">E-mail:</label>
<input type="email" class="email" id="email" required placeholder="Enter your e-mail">
</div>
</div>