jquery Learning Notes (4)--jquery a specific idea for getting a column value in a table _jquery

Source: Internet
Author: User
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!

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.