Jquery如何放置一个按钮

时间:2015-04-20 08:48:10

标签: javascript jquery

当鼠标悬停时,我有一个垃圾桶出现在文本的右侧(" cell.value.name")。但我需要它出现在文本的右侧。任何想法怎么做?

if (cell.direction == 'out') {
          var btnColumn = $('<div><div class="cellName" data-cellId="' + cell.fatherId +'" data-direction="' + cell.direction + '" +">' + cell.value.name + '</div></div>')
        } else {
          var btnColumn = $('<div><div class="cellName" data-cellId="' + cell.fatherId +'" data-direction="' + cell.direction + '" +">' + cell.value.name + '</div></div>')
        }

事件监听器;

$(document).off('mouseleave', '.cellName').on('mouseenter', '.cellName', function (event) {
var elem = event.target || event.srcElement;
 var trashCan = $('<button type="button" title="Remove" class="btn btn-default btn-xs x-button-icon btn-delete-port" data-cellId="" data-direction=""><span class="glyphicon glyphicon-trash"></span></button>');
$(elem).mouseenter(function() {
   // $(this).append(btnColumn);
   trashCan.appendTo($(this));
  })
  .mouseleave(function() {
   trashCan.fadeOut();
  });


});

0 个答案:

没有答案