It took one night to solve a seemingly easy problem. In this task, you need to obtain an ID value in a column. This problem does not exist if you use the common method of passing JS values. However, all jquery plug-ins are used this time, including various pop-up boxes, if you use JS to pass values, you have to use the ugly pop-up box of JS. So, you know.
I found a lot of methods on the Internet, but I couldn't use them. Later I thought of the mouse event in jquery. I could get the values of the current row and column when I move the cursor over the table. The page is as follows:
The specific operation is to click the "delete" button and then call the jquery plug-in page. At this time, you need to obtain the "ID" of the corresponding line for the operation. My method is:
First, define a global variable for the number of rows and columns, and then obtain the number of rows and columns of the row when the mouse goes through the button, and pay the global variable:
Copy codeThe Code is as follows:
Var trNum;
Var tdNum;
$ (Function (){
// Define a mouse event
$ ('# Users td'). hover (
Function (){
// Obtain the row number of the table
TrNum = $ (this). parent (). parent (). find ('tr '). index ($ (this). parent () [0]) + 1;
// Obtain the column number of the table
TdNum = $ (this). parent (). find ('td '). index ($ (this) [0]) + 1;
}
);
Here, "users" is the ID of this table, and then the business is processed according to this ID, as shown below:
Copy codeThe Code is as follows:
01. // click "pop-up box" and select "OK" for Business Processing
$ ("# Dialog-confirm"). dialog ({
AutoOpen: false,
Resizable: false,
Height: 150,
Modal: true,
Buttons :{
"OK": function (){
Var au_id = $ ('# users '). find ('tr: eq ('+ (trNum) + ')'). find ('td: eq (0 )'). text (); // obtain the ID value of the first column
// Service Processing omitted
......
},
"Cancel": function (){
$ (This). dialog ("close ");
}
}}
);
Small Problems combine great wisdom. It is the truth I have always advocated to improve my learning ability and problem-solving ability by solving problems!