项目作者: hubgit

项目描述 :
jQuery plugin for HTML Microdata
高级语言: JavaScript
项目地址: git://github.com/hubgit/jquery-microdata.git
创建时间: 2014-01-02T17:03:28Z
项目社区:https://github.com/hubgit/jquery-microdata

开源协议:MIT License

下载


jQuery Microdata

Extract and manipulate objects stored in HTML Microdata.

Demonstration

Get all items of a certain type

$(node).items(itemtype)

  1. $('#albumlist').items('http://schema.org/MusicAlbum')

Get the property nodes of an item

item.property(property) => a set of jQuery nodes

  1. $(node).property('name') => [ node ]
  2. $(node).property('byArtist').eq(0).property('album') => [ node, node ]

Get the value of a property

property.value() => the itemValue of the node(s)

  1. $(node).property('name').value() => string
  2. $(node).property('byArtist').eq(0).property('name').value() => string

Get the values of a property as an array

property.values() => array of the itemValues of the nodes

  1. $(node).property('name').values() => [ string, string ]

Set a property

item.property(property).value(value)

  1. $(node).property('name').value('Yellow Submarine')

Set one of multiple properties with the same name

item.property(property).eq(index).value(value)

  1. $(node).property('name').eq(1).value('Yellow Submarine')

jQuery Things

The plugin also provides a convenience method for working with items (“things”) where there is only a single instance of each property. This is analogous to jQuery’s data method.

Get a property of an item

item.microdata(key)

  1. $(node).microdata('name');

Set a property of an item

item.microdata(key, value)

  1. $(node).microdata('name', 'The Beatles');

Set multiple properties of an item

item.microdata({ key: value })

  1. $(node).microdata({
  2. name: 'The Beatles',
  3. url: 'https://en.wikipedia.org/wiki/The_Beatles'
  4. });

Get all properties of a single item or a collection of matched items

collection.microdata()

  1. $(node).microdata()
  2. $('#albumlist').items('http://schema.org/MusicAlbum').microdata()