2012-10-10 29 views

回答

1

試試這個請:工作演示http://jsfiddle.net/77L4w/

希望這將適合的原因:)

代碼

$('#movecam').draggable({ 
    drag: function() { 
     $('#mecam').css('top', $(this).position().top); 
     $('#mecam').css('left', $(this).position().left); 
    }, 
    stop: function() { 
     $('#mecam').css('top', $(this).position().top); 
     $('#mecam').css('left', $(this).position().left); 
    } 
}); 

$("#movecam").bind("contextmenu", function(event) { 
    event.preventDefault(); 
    $("div.custom-menu").hide(); 
    $("<div class='custom-menu'><input id='propertz' type='button' name='propertz' value='Properties'></div>").appendTo("body").css({ 
     top: event.pageY + "px", 
     left: event.pageX + "px" 
    }); 

    init_prperty_click() 
}).bind("click", function(event) { 
    $("div.custom-menu").hide(); 
}); 

$('input[name="closeme"]').click(function() { 
    $("#movecam").hide(); 
}); 

function init_prperty_click() { 
    $("input[name=propertz]").on('click', function() { 
     alert("haha"); 
    }); 
}​