我有一個HTML結構,我想刪除一個額外的項目。刪除標記時刪除標記
<div class="tokenfield form-control">
<input class="pro-credit-user" name="pro-credit-users[]" placeholder="Person or business name" style="position: absolute; left: -10000px;" tabindex="-1" type="text">
<input style="position: absolute; left: -10000px;" tabindex="-1" type="text">
<div class="token invalid">
<span class="token-label" style="max-width: 152px;">dfgdfgdf</span>
<a href="#" class="close" tabindex="-1">×</a>
</div>
<input class="token-input ui-autocomplete-input" autocomplete="off" placeholder="Person or business name" id="1479230390171168-tokenfield" tabindex="0" style="min-width: 60px; width: 1237.4px;" type="text">
</div>
<a class="delete-pro-credit" href="#">Delete</a>
<span class="pro-credit-error" style="color:red;float:right">Sorry, this user cannot be found. We will not be able to link this persons name with an Enjoius account</span>
我有jQuery的代碼也:
$("input.pro-credit-user").last().on('tokenfield:removetoken', function (e) {
$(this).closest('span').remove(); // not working
})
當用戶刪除令牌我也想刪除它有一流的「親信貸錯誤」的跨度。我寫了jQuery,但它不工作。
如何刪除包含'pro-credit-error'類的範圍?
在你的代碼中'.pro-credit-user'沒有父'span'元素? – adeneo
什麼是''tokenfield:removetoken''? – j08691
@ j08691它與http://sliptree.github.io/bootstrap-tokenfield/#examples –