Jquery隐藏带占位符的文本

时间:2017-09-07 20:05:59

标签: javascript jquery text placeholder

我试图通过仅通过其占位符查找文本字段而在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>

感谢您的帮助:)

2 个答案:

答案 0 :(得分:1)

&#13;
&#13;
$("input[placeholder='credit card number']").hide();
&#13;
<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"/>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

使用attribute equals selector

$('[placeholder="credit card number"]').hide();