<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>
删除包含类“错误”的p标记的最有效方法是什么?我应该在类标签容器上使用hasClass吗?但那我如何才能删除?
答案 0 :(得分:6)
$('.error').remove()
怎么样?
或更具体的$('p.error').remove()
。