我的向上和向下箭头位于一个向下几个 div 的 div 中,也是一个图像。当我单击箭头时,我需要使用类名句柄移动 div。如果我将句柄放在选择器中,代码可以正常工作,但我不想单击句柄,我希望能够单击图像,但我似乎无法让选择器足够高。
<script>
$(document).ready(function(){
$('.moveUp2').click(function(){
var diveItem = $(this).parent();
if (diveItem.prev().is('div'))
{
diveItem.insertBefore(diveItem.prev())
}
});
$('.moveDown2').click(function(){
var diveItem = $(this).parent();
if (diveItem.next().is('div'))
{
diveItem.insertAfter(diveItem.next())
}
})
});
</script>
<div style="background-color: #dceaf4;" class="handle">
<div style="float:left;"><b class="order_interaction" id="interactionOrder">{{order}}.</b> </div>
<div style="float:left;"><b id="interactionType">{{type}}</b></div>
<div style="width:100%; text-align:right;">
<div style="text-align:right;">
<a href="#" class="interactionComments">
<img style="cursor:pointer;" title="Comments" src="img/messages.png"/>
</a>
{{#if showControls}}
<a class="moveUp_interaction">
<img style="cursor:pointer;" src="img/arrow_up_blue.png" class="moveup2" title="Move Up">
</a>
<a class="moveDown_interaction">
<img style="cursor:pointer;" src="img/arrow_down_blue.png" class="movedown2" title="Move down">
</a>
<a class="del_interaction">
<img style="cursor:pointer;" src="img/delete.png" class="delete" title="Delete">
</a>
{{/if}}
</div>
</div>
</div>