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: