<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<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" />
  
  <style type="text/css">
   BODY,
   HTML {
    padding: 0px;
    margin: 0px;
   }
   BODY {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 11px;
    background: #FFF;
    padding: 15px;
   }
   
   H1 {
    font-family: Georgia, serif;
    font-size: 20px;
    font-weight: normal;
   }
   
   H2 {
    font-family: Georgia, serif;
    font-size: 16px;
    font-weight: normal;
    margin: 0px 0px 10px 0px;
   }
   
   #myDiv {
    width: 150px;
    border: solid 1px #2AA7DE;
    background: #6CC8EF;
    text-align: center;
    padding: 4em .5em;
    margin: 1em;
    float: left;
   }
   
   #myList {
    margin: 1em;
    float: left;
   }
   
   #myList UL {
    padding: 0px;
    margin: 0em 1em;
   }
   
   #myList LI {
    width: 100px;
    border: solid 1px #2AA7DE;
    background: #6CC8EF;
    padding: 5px 5px;
    margin: 2px 0px;
    list-style: none;
   }
   
   #options {
    clear: left;
   }
   
   #options INPUT {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 11px;
    width: 150px;
   }
   
  </style>  
  
  <script src="jquery.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 #myDiv is clicked
    $("#myDiv").contextMenu({
     menu: 'myMenu'
    },
     function(action, el, pos) {
    
                     alert(
      'Action: ' + action + '\n\n' +
      'Element text: ' + $(el).text() + '\n\n' +
      'X: ' + pos.x + '  Y: ' + pos.y + ' (relative to element)\n\n' +
      'X: ' + pos.docX + '  Y: ' + pos.docY+ ' (relative to document)'
      );
    });
    
    // Show menu when a list item is clicked
    
    
    
    $("#myList UL LI").contextMenu({
     menu: 'myMenu'
    }, function(action, el, pos) {
    //action 指 <li class="edit"><a href="#edit">Edit</a></li>中的 #edit
    // el 指右键的选项 如 <li>Item 1</li>,若为<div >Quit</a></li>
  </ul>
  
 </body>
</html>

相关文章:

  • 2021-08-17
  • 2021-06-25
  • 2021-09-15
  • 2021-12-07
  • 2021-10-23
  • 2022-12-23
  • 2021-08-15
  • 2022-02-15
猜你喜欢
  • 2021-08-11
  • 2021-11-03
  • 2021-06-11
  • 2021-12-27
  • 2022-01-20
  • 2021-12-28
  • 2021-08-09
相关资源
相似解决方案