Reputation: 9049
<div id="info-leftside">
<div class="label-container" id="name-label"><p class="info-field-label">name</p><p class="error">error</p></div>
<input type="text" name="name" id="name" class="field"/>
<div class="label-container" id="email-label"><p class="info-field-label">email</p></div>
<input type="text" name="email" id="email" class="field"/>
<div class="label-container" id="phone-label"><p class="info-field-label">phone</p><p class="error">error</p></div>
<input type="text" name="phone" id="phone" class="field"/>
<div class="label-container" id="address1-label"><p class="info-field-label">address (line 1)</p></div>
<input type="text" name="address1" id="address1" class="field"/>
<div class="label-container" id="address2-label"><p class="info-field-label">address (line 2)</p></div>
<input type="text" name="address2" id="address2" class="field"/>
<div class="label-container" id="city-label"><p class="info-field-label">city</p></div>
<input type="text" name="city" id="city" class="field"/>
</div>
What would be the most efficient way of removing the p tags that contain the class 'error'? Should I use hasClass on the class label-container? But then how do I remove if true?
Upvotes: 0
Views: 1034
Reputation: 79830
How about $('.error').remove()
?
or to be more specific $('p.error').remove()
provided if you are using same class for some other elements.
Upvotes: 6