2012-05-20 11 views
6

ठीक है तो मैं इस संरचनाकैसे मैं jQuery के साथ एक बाहरी div निकालूँ

<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 को हटा

मैं भीतरीको हटा सकते हैंपहले लेकिन सुनिश्चित करें कि बाहरी

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

कोई भी विचार

उत्तर

8

उपयोग replacewith() विधि को निकालने का तरीका नहीं,

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

here is the fiddle example

संबंधित मुद्दे