Because now officially is 2.0 of the document (Http://docs.jquery.com/Plugins/Metadata), 1.0, I have not read, but 2.0 of the example runs very normal.
! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> Translation:
attr: Internal property, parameter name points to property name
Class: Property of the inner class, wrapped with {}
Elem: An inner child element, such as a script tag. The name of the parameter points to the element name.
function:
Metadata (options) return jquery object
Extracts metadata, caches, and returns metadata from the first element of a jquery collection.
Arguments:
Options (Optional) options
A set of key/value pairs that define the type of metadata to extract. All options are optional.
Options:
The options in metadata are available in three types: type, name, single
Type String Default: ' Class '
Specifies the expected position of the element. The possible values are "class": Search in the Class attribute, "' Elem": Search for elements within the search element, and "attr": The custom attribute search in the element.
Search for metadata in a class, not in a class.
$ (". Selector"). Metadata ({ type: ' attr ')
name String Default: ' Metadata '
When the type is "attr", specify the name of the custom attribute to search for. When the type is "Elem", specify the tag name of the element to search for.
A custom element property named "jdata" is searched for metadata.
$ (". Selector"). Metadata ({ type: ' attr ', name: ' Jdata ' })
Single String Default: ' Metadata '
Given the name of the data extracted from the jquery cache element.
Store and retrieve the cached data extracted into a project named "Jdata in jquery."
$ (". Selector"). Metadata ({single : ' Jdata ' })
Examples:
Gets metadata from the class attribute.
<li class= "SomeClass {some: ' data '} anotherclass" >...</li> <script>alert ($ (' Li.someclass '). Metadata (). some);</script>
Gets metadata from a custom attribute.
<li data= "{some: ' random ', JSON: ' Data '}" >...</li> <script>alert ($ (' Li.someclass '). Metadata ( {type: ' attr ', Name: ' Data '}). Some);</script>
Gets metadata from a child element.
<li class= "SomeClass" ><script type= "Application/json" >{some: "JSON", data:true}</script>...</ Li> <script>alert ($ (' Li.someclass '). Metadata ({type: ' Elem ', Name: ' Script '}). Some);</script>
jQuery.metadata.setType (type, name) Returns:null
Sets the default type and name options for all of the following metadata requests.
Arguments:
Typestring
Specifies the expected position of the element. Possible values are "class" (default): Search in Class properties, "Elem": meta-search in meta-search, and "attr": custom attribute search in elements.
Name string
The name of the tag or attribute to search for based on the value of the type option.
Set the metadata plug-in to find custom properties.
<li data= "{some: ' random ', JSON: ' Data '}" class= "SomeClass" >...</li> <script> $. Metadata.settype (' attr ', ' data '); Alert ($ (' Li.someclass '). Metadata (). some);
jQuery.metadata.get (Elem, Options) Returns:object
Sets the default type and name options for all of the following metadata requests.
Arguments:
Elem Element
The element that contains the metadata to extract.
Options (Optional) options
A set of key/value pairs that define the type of metadata to extract. All options are optional. View the metadata plug-in page for more information.
Set the metadata plug-in to find custom properties.
<li class= "SomeClass {some: ' random ', JSON: ' Data '} ' >...</li> <script> $ (' Li.someclass '). each (function () { var data = $.metadata.get (this); alert (data.some); }); </script>
Example:
<li id= "Li1" class= ' SomeClass {"item_id": 1, "Item_label": "Label"} ' >item 1</li> <li id= ' Li2 ' metadata= ' { "item_id": 1, "Item_label": "Label"} ' >item 2</li> <li id= "Li3" > <metadata style= "Display:none;" >{"item_id": 1, "Item_label": "Label"}</metadata> Item 3 </li> <li id= "Li4" > <script ty Pe= "metadata" >{"item_id": 1, "Item_label": "Label"}</script> Item 4 </li> $ (function () {$ ("#i Tem1 "). Metadata (). item_id; 1 $ ("#item1"). Metadata ({"Type": "Class"}). item_id; 1 $ ("#item2"). Metadata ({"type": "attr"}). Item_label; "Label" $ ("#item2"). Metadata ({"type": "attr", "name": "Metadata"}). Item_label; "Label" $ ("#item3"). Metadata ({"type": "Elem"}). Item_label; "Label" $ ("#item3"). Metadata ({"type": "Elem", "name": "Metadata"}). Item_label; "Label" $ ("#Item4 "). Metadata ({" type ":" Elem "," name ":" Script "}). Item_label; "Label"});
jquery metadata Detailed