It took one night to solve a seemingly easy problem. This thing that you're doing tonight because you want to get an ID value from a column. If you use the usual kind of JS to pass the value of the way this problem does not exist, but because this is used are jquery plug-ins, including a variety of pop-up boxes, with JS to pass the value of JS that is to use the ugly pop-up box, so you know.
On the internet to find a lot of methods, not to use, and then think of jquery in the mouse events, you can pass the table when the mouse, get the current row and column values. The page looks like this:
The specific action is to click the "Delete" button, and then call the jquery plug-in page, this time need to get the corresponding line "ID" to operate. My approach is to:
Define a global variable for the number of rows and columns, and then get the number of rows and columns of this row and pay this global variable when the mouse passes the button:
Copy Code code as follows:
var trnum;
var tdnum;
$ (function () {
Define a mouse passing event
$ (' #users TD '). Hover (
function () {
Get the row number of a table
Trnum = $ (this). Parent (). Parent (). Find (' tr '). Index ($ (this). Parent () [0]) + 1;
Get the column number of a table
Tdnum = $ (this). Parent (). Find (' TD '). Index ($ (this) [0]) + 1;
}
);
Where "users" is the ID of this table. And then do business processing based on this ID, as follows:
Copy Code code as follows:
01.//Click "Pop-up box" to select "OK" after the 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 (); Get the ID value for the first column
Business processing ellipsis
......
},
"Cancel": function () {
$ (This). dialog ("Close");
}
}}
);
Small problems gather great wisdom, through solving problems to improve their ability to learn and solve problems, I have been advocating the truth!