0
我正在写一个小的咖啡文字从HTML中删除一个列表。这是我的样本HTML:JQuery最接近()选择器不工作
<li class="picture col-xs-3" id="picture_38">
<div class="thumbnail">
<img src="/system/uploads/picture/image/38/thumb_ASUS_EeePadMeMo_2.jpg">
<div class="caption">
<a class="btn red btn-xs img_action_remove" data-method="delete" data-remote="true" href="/admin/galleries/3/pictures/38" rel="nofollow" title="Remove">
Delete
</a>
</div>
</div>
</li>
我有几个里的项目,我需要删除列表中的项目当我点击链接与img_action_remove
标签。这是我的脚本:
$ ->
$('.img_action_remove').bind 'ajax:success', (event, data, status, xhr) ->
$(this).closest('li').remove()
对我来说看起来不错,但我敢肯定,我错过了穿越DOM的东西。
你确定链接实际上并没有在href中导航到页面,并且事件处理程序中的this是元素。 – adeneo
你能修正这个例子,以正确的代码格式?这真是愚蠢的看起来;) – brandonscript
事件'ajax:success'从哪里来? – charlietfl