2017-09-07 136 views
1

我想隱藏一個文本字段在jquery中尋找文本字段只能通過它的佔位符,沒有別的。我的目標是這樣的:Jquery隱藏文本的佔位符

$(look for placeholder with the name credit card number).hide(); 

我不想使用IDS或類來尋找這個文本字段,只有佔位符。

下面是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

'$('[placeholder ='信用卡號碼']')。hide()' –

回答

1

$("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"/>

+0

在前面添加輸入的目的是什麼?如在中,它與沒有輸入有什麼不同? – MGames

+0

更確切地說,最好編寫完整的Selector。因爲在textarea中可能有一個佔位符相同的標題 –

+0

聽起來不錯,謝謝! – MGames