Methods of jquery data storage

Source: Internet
Author: User

1. Preface

jquery allows the jquery object to be treated as a temporary "data store Center" where developers can store data in Key-value pairs in jquery objects, and the forest jquery object can remove previously stored data and delete previously stored data. The data stored in the jquery object can be either a basic type value or an array, a JavaScript object, and so on. The data store-related methods supported by JQuery objects are as follows:

1) data (Name,value): Stores the Name:value data pair to the jquery object.

2) data (object): Multiple name:value data pairs are deposited into the jquery object at one time. Where object is a shape like {name:value ...} The object.

3) data (): Gets all the data stored in the jquery object. The method returns a {Name:value ...} form of the object

4) Removedata ([name]): Deletes the data stored in the jquery object with the key name.

5) Removadata ([list]): Delete data for multiple keys listed by list.

In addition to this, the jquery namespace provides some tool methods for data storage, which are used to store data on an element.

1) jquery.data (element,key,value): Stores key:value data on element elements

2) Jquery.data (Element,key): Gets the value that corresponds to the specified key on element.

3) Jquery.data (Element): Gets all key:value pairs on element elements.

4) Jquery.removedata (Element[,key]): delete element specified Keya corresponding data item

5) Jquery.hasdata (Element): Determine if data has been stored on element elements

2. Example

The following code demonstrates the data storage-related methods of jquery

<! DOCTYPE Html>

3. Running Results

Methods of jquery data storage

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.