我创建了一个contextmenu来显示特定类,但是当我克隆具有该类的元素时,不会contextmenu显示。
显示上下文菜单:
// Trigger action when the contexmenu is about to be shown
$(".ui-editable").bind("contextmenu", function (event) {
// Avoid the real one
event.preventDefault();
//Save the selected and the parent element
selected_area = $(this);
parent_area = $(this).parent();
$(this).addClass('selected-menu')// Show contextmenu
$("#editContextMenu").finish().toggle(100).
// In the right position (the mouse)
css({
top: event.pageY + "px",
left: event.pageX + "px"
});
});
克隆元素:
function cloneBlock() {
$(selected_area).clone().appendTo(parent_area);
}
完整的示例在这里: https ://jsfiddle.net/marana12/xsd2n9uo/9/
qq_花开花谢_0
相关分类