JQuery getting table data example code _ jquery-js tutorial

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

}

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.