jquery bulk modifies the name value, adding the name suffix in bulk, not each (no loops required)

Source: Internet
Author: User

Background

form fields, configuring the Where property to automatically refresh to the Queryable area, query fields need to add _where suffix, response background rules


Problem

Batch set query field, you must increase the _where suffix in bulk to normal query. Each loop is a bit cumbersome, there is no more convenient batch modification method.


Investigation

The direction is jquery batch modification name, the entire internet is flooded with. attr ("name", "New_value"). Only single-value modifications, eventually, found this systematic article

Jquery attr () method property assignment and property acquisition

jquery uses the attr () method to get and set element properties, attr is the abbreviation for attribute (attribute), which is often used in jquery DOM operations to attr (), and attr () has 4 expressions.

1. attr ( attribute name ) //Get the value of the property (Gets the property value of the first matching element. This method makes it easy to get the value of an attribute from the first matching element. Returns undefined if the element does not have a corresponding attribute)

2. attr ( property name, property value ) //Set the value of the property (set a property value for all matching elements.) )

3. attr ( attribute name , function value ) //Set the function value of the property (set a computed property value for all matching elements.) Instead of providing a value, you provide a function that is evaluated by the function as the value of the property. )

4.attr (properties) //Set multiple attribute values for the specified element: {attribute name one: attribute value one, property name two: "Property value Two", ...}. (This is the best way to set many properties in bulk in all matching elements.) Note that if you want to set the class property of an object, you must use ' className ' as the property name. Or you can use ' class ' or ' id ' directly. )

Reference

Scheme

The use of the program is 3rd, the source code is as follows

Note the function form of scenario 3rd, which is the code $ ("Input[where]") for Each loop. attr ("name", function () {return this.name+ "_where"});


Summarize

Perfect solution, skip each loop code block and look at the tall

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/06/D9/wKiom1m_dL_xYQCfAAAPS9QbbsY683.jpg "title=" Qq20170918152449.jpg "alt=" Wkiom1m_dl_xyqcfaaaps9qbbsy683.jpg "/>


2017-09-18 15:25

Mo Mo Jin

In Xi ' An Hui Xin IBC

This article is from the "foam gold it experience and skills" blog, please be sure to keep this source http://zl0828.blog.51cto.com/2242565/1966363

jquery bulk modifies the name value, adding the name suffix in bulk, not each (no loops required)

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.