.metadata()
Categories: Utilities
.metadata( [ options ] )Returns: Object
Plugin: jQuery.metadata
Description: Extracts, caches, and returns metadata from the first element in the jQuery collection.
The .metadata()
method is capable of extract data from classes, random attributes, child elements and HTML5 data-* attributes.
Attention: .metadata()
could be in conflict with .metaparse()
, be sure to prevent conflicts use different modes for these methods.
-
Extract data from the first element in the jQuery collection.
HTML:
<li class="someclass {some: 'data'} anotherclass">...</li>
Code:
var data = $('li.someclass').metadata();
if( data.some && data.some == 'data' )
alert('It Worked!');
-
type
version added: 1.0
Specify the expected locations of metadata for the element. Possible values are 'class': search in the class attribute, 'elem': search for an element inside the element being searched, and 'attr': search in a custom attribute on the element.
Default: 'class'
-
name
version added: 1.0
When type is 'attr', specify the name of the custom attribute for which to search. When type is 'elem', specify the tag name of the element for which to search.
Default: 'metadata'
-
single
version added: 1.0
The name given to the data extracted from the element in the jQuery cache.
Default: 'metadata'