Menu de contexto com JQuery

De Basef
Ir para: navegação, pesquisa

Exemplo:

<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
<title>jQuery Context Menu Plugin Demo</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
 
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="jquery.contextMenu.js" type="text/javascript"></script>
<link href="jquery.contextMenu.css" rel="stylesheet" type="text/css" />
 
<script type="text/javascript">
 
    $(document).ready( function() {
 
       // Show menu when a list item is clicked
       $("#myList UL LI").contextMenu({
          menu: 'myMenu'
       }, function(action, el, pos) {
          alert(
             'Action: ' + action + '\n\n' +
             'Element text: ' +$(el).attr('id')
          );
       });
 
    });
 
</script>
</head>
 
<body>
 
    <div id="myList">
        <ul>
            <li id="1">Item 1</li>
            <li id="2">Item 2</li>
            <li>Item 3</li>
            <li>Item 4</li>
            <li>Item 5</li>
            <li>Item 6</li>
        </ul>
    </div>
 
 
    <ul id="myMenu" class="contextMenu">
        <li class="edit"><a href="#edit">Editar</a></li>
        <li class="cut separator"><a href="#cut">Colar</a></li>
        <li class="copy"><a href="#copy">Copiar</a></li>
        <li class="paste"><a href="#paste">Colar</a></li>
        <li class="delete"><a href="#delete">Deletar</a></li>
        <li class="quit separator"><a href="#quit">Sair</a></li>
    </ul>
 
 </body>
</html>