6

わかりましたので、私はこの構造を持っています

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

field_with_errors外側と内側のメッセージを削除して、入力タグだけを残すにはどうすればよいですか

私が行った場合

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

div全体を削除します

インナーは外せる.messageけどアウターの外し方がわからない

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

何か案は

4

2 に答える 2

8

使用replacewith()方法、

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

ここにフィドルの例があります

于 2012-05-20T13:26:08.240 に答える
5

メソッドを使用できますreplaceWith()

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

http://jsfiddle.net/mgy9W/

于 2012-05-20T13:26:44.993 に答える