2012-05-20 5 views
6

と外側のdivを削除しないので、私は外field_with_errorsと内側のメッセージを削除し、私はどのように私は、[OK]をjqueryの

を行う場合だけでinputタグ

を残すにはどうすればよい。この構造に

<div class="field_with_errors"> 
    <input id="count" name="count" size="2" type="text" /> 
    <label class="message" for="count_for">Required</label> 
</div> 

を持っています

$("#count").closest(".field_with_errors").remove() 

それは

私はインナーを削除することができ、全体のdivを削除しますあなたがreplaceWith()メソッドを使用することができます

$(".field_with_errors").replaceWith($("#count"));​ 

here is the fiddle example

答えて

5

、最初ますが、外

$("#count").closest(".field_with_errors").find('.message').remove() 

任意のアイデア

関連する問題