3
안녕하세요 저는 JQuery를 처음 사용하기 때문에 마우스 오른쪽 버튼으로 컨텍스트 메뉴를 갖고 싶습니다. 내가 봤 거든 샘플 코드를 찾았 어JQuery 마우스 오른쪽 버튼을 클릭하면 컨텍스트 메뉴
이것은 내가 사용하고있는 코드이다.
$(document).ready(function(){
$('#rightclickarea').bind('contextmenu',function(e){
var $cmenu = $(this).next();
$('<div class="overlay"></div>').css({left : '0px', top : '0px',position: 'absolute', width: '100%', height: '100%', zIndex: '100' }).click(function() {
$(this).remove();
$cmenu.hide();
}).bind('contextmenu' , function(){
return false;}).appendTo(document.body);
$(this).next().css({ left: getLeftPosition(e), top: getTopPosition(e), zIndex: '101' }).show();
return false;
});
$('.vmenu .first_li').live('click',function() {
if($(this).children().size() == 1) {
//alert($(this).children().text());
$('.vmenu').hide();
$('.overlay').hide();
}
});
$('.vmenu .inner_li span').live('click',function() {
//alert($(this).text());
$('.vmenu').hide();
$('.overlay').hide();
});
$(".first_li , .sec_li, .inner_li span").hover(function() {
$(this).css({backgroundColor : '#E0EDFE' , cursor : 'pointer'});
if ($(this).children().size() >0)
$(this).find('.inner_li').hide();
$(this).css({cursor : 'default'});
},
function() {
$(this).css('background-color' , '#fff');
$(this).find('.inner_li').hide();
});
});
제 문제는 모든 것이 올바르게 작동하는 것입니다. 하지만 다시 rightclick하면 아무 것도 나타나지 않습니다. 메뉴를 다시 표시하려면 중간 왼쪽 클릭을하고 오른쪽 클릭을 다시해야합니다. 사람이
전체 페이지를 보내면 실행하고 디버깅 할 수 있습니까? –