This article mainly introduces how to obtain table data through JQuery. The following is a good example. You can refer to the following table:
Click Delete and save. You need to execute the onclick event SaveItem ("<% # Eval (" ID ")>", this );
In JS
The Code is as follows:
Function SaveItem (id, btn)
{
Var tbl = $ (btn). parent ();
// Record the second row of table
Var dj = tbl. children (). eq (1 ). chilren (). eq (3 ). find ("INPUT "). attr ("value"); // The find method returns an array, but here it is an element, which can be written like this. If multiple elements exist, you can use the Selector Used by Jquery to confirm the selection of a specific element or use enumeration: In find ("INPUT"). each (function (I ){
// Alert ($ (this). attr ("value "));
// Assign a value
$ (This). attr ("value", "YOUR_VALUE ");
})
Var content = tbl. children (). eq (2 ). children (). eq (1 ). find ("TEXTAREA "). text (); // the content of the text box in the third column of the third row is found here. If you use ASP. net asp. NET TextBox Control and Multiline mode. Here, the TagName is 'textta', which is obtained using the attr ("value") method or the text () method.
Var mark = tbl. children (). eq (3 ). children (). eq (1 ). find ("INPUT "). attr ("value"); // obtain the value of the value text box in the third column of the fourth row.
}