Intelligent right Key menu _javascript technique based on javascript

Source: Internet
Author: User
Tags ticket

Through this article to introduce the Smart right button menu, need to introduce the file will be given at the end of the text, first show you the code:

The specific code looks like this:

var cityarray = new Array (); 
Cityarray.push ("Beijing"); 
Cityarray.push ("Shanghai"); 
Sets the table header's Mouse right-click event $ (' th '). MouseDown (function (e) {var selected = e.target.innerhtml; 
3 represents the right key if (e.which==3) {if (selected== "booking type") {var opertion ={name: "Booking Type"}; 
var data = [[{text: ' Out of ticket ', Func:function () {alert ("Out of ticket ');" 
}],[{text: ' Leave a ticket ', func:function () {alert ("Leave the Ticket"); 
}],[{text: ' Change sign ', func:function () {alert ("change"); 
}],[{text: ' Refund ', func:function () {alert ("refund"); 
}}],[{text: ' All ', func:function () {alert ("all"); 
} 
}]]; 
$ (this). Smartmenu (data,opertion); 
}else if (selected== "departure city") {var opertion ={name: "Departure City"}; 
var data = []; 
for (Var i=0;i<cityarray.length;i++) {//Use closures (function (i) {func = function () {alert (cityarray[i)); 
}) (i); 
var obj = {Text:cityarray[i], func:func}; 
var cArray = new Array (); 
Carray.push (obj); 
Data.push (CArray); 
var other = {text: all, func:function () {alert ("all"); 
} var Otherarray = new Array (); Otherarray.push (other);
Data.push (Otherarray); 
$ (this). Smartmenu (data,opertion); } return false;//block link jump});

$ (' th ') specifies the label with the right key, according to the actual to determine that I am here added to the table header, so is th label
E.which = 3 is the right key

Two things are listed here

One is the content on the menu. Determines the name of the right-click menu with the previous opertion, to be unique

The other is not sure you can get the data from the server, stored in the array, I wrote here dead, and then implemented in a second way it requires a closure

Files to introduce: http://download.csdn.net/detail/u012116457/9449905

The above content is small make up for everyone to share based on JavaScript implementation of Intelligent right menu of knowledge, hope to help everyone!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.