我试图通过仅由占位符寻找文本字段而在jQuery中隐藏文本字段,而没有其他内容。我的目标是这样:
$(look for placeholder with the name credit card number).hide();
我不想使用ID或类来寻找此文本字段,只有占位符。
这是html:
<div class="form-wrap">
<table id="credit-card-table">
<tbody>
<tr id="credit_card_number_row">
<td class="field has-float-label">
<input id="credit_card_n" name="credit_card[cnb]" size="30" value="" placeholder="credit card number" autocorrect="off" autocapitalize="off" maxlength="19" class="" type="tel">
<span class="msg"> </span></td>
</tr>
<tr id="exp_date_row">
<td>
<table>
<tbody>
<tr>
感谢您的帮助:)
$("input[placeholder='credit card number']").hide();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="credit_card_n" name="credit_card[cnb]" size="30" value="" placeholder="credit card number" autocorrect="off" autocapitalize="off" maxlength="19" class="" type="tel"/>
使用属性等于选择器:
$('[placeholder="credit card number"]').hide();