2016-09-29 4 views
0

jQueryの内部の要素を選択しはjQueryのは、すべての入力、テキストエリアからクラスを削除し、特定のdiv内の要素を選択し、すべての入力、テキストエリアからクラスを削除し、特定のdiv

どのようにすべての入力からのjQueryを使用してクラスを削除するには、特定のdiv内のtextareaとselect要素

次のように私のHTMLに見える:

<h4 class="subHead02">Personal Statement 
    <span class="action-container"> 
     <a href="javascript:;" class="edit-link"> 
      <i class="icon-edit"></i> 
     </a> 
    </span> 
</h4> 
<div class="profile_info_wrap"> 
    <input type="text" value="test" class="hide"/> 
    <textarea class="hide" ros="3" cols="10">I am in text area</textarea> 
    <select class="hide"> 
     <option>one</option> 
     <option>two</option> 
    </select> 
    <input type="text" value="hello" class="hide"/> 
</div> 

編集リンク(クラス=「編集リンク」とアンカータグ)をクリックしたとき、私は、すべての入力からテキストをクラス「非表示」を削除したいですクラス "profile_info_wrap"でdiv内の要素と要素を選択します。次のようにしようとしました

jQuery(this).parent().parent().next(".profile_info_wrap").find("select,textarea, input").removeClass('hide'); 

しかし、それは動作しません。すべてのヘルプは大幅に親を使用しての

+6

__TYPO__ _this_を固定するのに参照している場合、その 'removeClassは()' 'remoceClass()'、あなたのコードが動作するはずはありません。したがって、それを閉じること – Satpal

+1

* "は動作しません" * - それ以上の詳細は? removeClass( 'hide'):コンソールのエラー(例えば、 "remoceClass not defined"? –

+0

$(this)).parents( "。subHead02")兄弟( "。 ; –

答えて

0

INSEADが

$(this).closest('.subHead02').next(".profile_info_wrap").find("select,textarea, input").removeClass('hide'); 

また正しいremoceClassremoveClass

として最も近いの使用は理解されるであろう。またクリック時、あなたのアンカータグのアクションはちょうどe.preventDefault();

$(function(){ 
 
    
 
    $('.edit-link').click(function(e){ 
 
    e.preventDefault(); 
 
    $(this).closest('.subHead02').next(".profile_info_wrap").find("select,textarea, input").removeClass('hide'); 
 
     
 
    }) 
 

 
})
.hide { 
 
    display: none; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<h4 class="subHead02">Personal Statement 
 
    <span class="action-container"> 
 
     <a href="#" class="edit-link"> 
 
      <i class="icon-edit">hello</i> 
 
     </a> 
 
    </span> 
 
</h4> 
 
<div class="profile_info_wrap"> 
 
    <input type="text" value="test" class="hide"/> 
 
    <textarea class="hide" ros="3" cols="10">I am in text area</textarea> 
 
    <select class="hide"> 
 
     <option>one</option> 
 
     <option>two</option> 
 
    </select> 
 
    <input type="text" value="hello" class="hide"/> 
 
</div>
を追加します

私はそれが助けてくれることを祈っています。それは下のスニペットで動作します。

0

あなたがタイプミス間違いremoveClassを(持っている)ではないremoceClass()

jQuery(this).closest('.subHead02').next(".profile_info_wrap").find("select,textarea, input").removeClass('hide'); 
0

ねえ、この

$('.edit-link').click(function(){ 
     $('.profile_info_wrap').find('.hide').each(function(){ 
      $(this).removeClass('hide'); 
     }); 
}); 

を試してみて、いくつかのタイプミスがあるかもしれませんので、携帯電話から投稿しています。

おかげ

+0

'$( '。profile_info_wrap')find( '。hide')removeClass( 'hide')'は動作し、 'each()'は必要ありません。 – Satpal

関連する問題