Quick extraction of web form data using jquery selector _ jquery

Source: Internet
Author: User
When you need to repeat the same thing multiple times, you can find a method that saves time and effort. The following describes how to use the jquery selector to quickly extract web form data, when doing the same thing on the web, you can find a method that saves time and effort when you need to repeat the same thing multiple times.

Before submitting a form on the web and verifying user input, document must be used in js when user input information is extracted. getElementById (), such a two form fields are okay, but there are many cases (I have encountered more than a dozen cases), so I personally dislike this method, but fortunately, I figured it out myself and found a convenient method using jquery.

I added an additional attribute to each form field of the data to be submitted, and replaced the original name attribute with an extra defined attribute "_ postField", such And so on. Then, use query to get all dom objects with the _ postField attribute and traverse them to encapsulate them into json key-value pairs whose value is key and whose content is value, the js method is as follows:

The Code is as follows:


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.