开发者

Get the value of the context menu items

HTML -

<ul id="myMenu" class="contextMenu">
    <li class="insert" onclick ="test();"><a href="#insert">Add New</a></li>        
    <li class="edit"><a href="#edit">Edit</a></li>                    
    <li class="delete"><a href="#delete">Delete</a></li>            
</ul>

jQuery -

jQuery(document).bind("contextmenu", function(e) {    
     return false;
     });

 jQuery('.even').bind("contextmenu", fun开发者_如何学运维ction(e) {    
     jQuery('#myMenu').css({        
         top: e.pageY+'px',        
             left: e.pageX+'px'    
             }).show();    
     return false;


     });

Context Menu is working fine. But i need to click on any of them, and it must be directed some function. for an example

function  test() {
alert("Helloooo")
}

Here the onlick function is not working... Please help me in this issue...

I'm so passionate to learn Jquery stuff as my project entirely relies on jquery and XML


well i guess the easiest way would be to bind the onclick event using jquery.. something like

jQuery('.insert a').click(function(){
  alert("handle the onclick event");
});

hope that helps


Just try to move your onclick attribute to anchor element like this:

<ul id="myMenu" class="contextMenu">
    <li class="insert"><a href="#insert" onclick="test();">Add New</a></li>        
    <li class="edit"><a href="#edit">Edit</a></li>                    
    <li class="delete"><a href="#delete">Delete</a></li>            
</ul>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜