好库网 好库网首页 | 我的好库
JQuery入门

$.meta.setType(type, name)-JQuery API

发布者:jquery2000
发布日期:2011/4/6 16:28:29   更新日期:2011/4/6 16:28:29
阅读次数:3254
评分:2.90
介绍:$.meta.setType(type, name) 设置元数据的类型. 元数据用JSON编码, 在JSON中的每个属性将成为该元素本身的属性.
正文:

$.meta.setType(type, name)

设置元数据的类型. 元数据用JSON编码, 在JSON中的每个属性将成为该元素本身的属性. 

There are three supported types of metadata storage: attr: Inside an attribute. The name parameter indicates which attribute. class: Inside the class attribute, wrapped in curly braces: { } elem: Inside a child element (e.g. a script tag). The name parameter indicates which element. The metadata for an element is loaded the first time the element is accessed via jQuery. As a result, you can define the metadata type, use $(expr) to load the metadata into the elements matched by expr, then redefine the metadata type and run another $(expr) for other elements.

 

返回值

undefined

 

参数

type (String): The encoding type 

name (String): The name of the attribute to be used to get metadata (optional) 

示例

说明:

Reads metadata from the class attribute

 

HTML 代码:

$.meta.setType("class") 

jQuery 代码:

<p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p> 

--------------------------------------------------------------------------------

 

说明:

 

Reads metadata from a "data" attribute

 

HTML 代码:

$.meta.setType("attr", "data") 

jQuery 代码:

<p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p> 

--------------------------------------------------------------------------------

 

 

说明:

Reads metadata from a nested script element

 

HTML 代码:

$.meta.setType("elem", "script") 

jQuery 代码:

<p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>


评论 [发表评论]
  • 怎么下载啊???晕!

    1
    njl_041x

    2011/9/16 23:00:24


  • 更多评论
账号 密码 还没帐号呢,现在注册一个?

免责声明:好库网所展示的信息由买卖双方自行提供,其真实性、准确性和合法性由信息发布人负责。好库网不提供任何保证,并不承担任何法律责任。