jquery.metadata.js 该js什么作用

JavaScript011

jquery.metadata.js 该js什么作用,第1张

Html代码

1.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

2.<html xmlns="http://www.w3.org/1999/xhtml">

3.<head>

4.<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />

5.<title></title>

6.<script type="text/javascript" src="jquery.metadata.2.0/jquery.metadata.2.0/test/jquery.js"></script>

7.<!-- 这里既引用了1.0又引用了2.0,就是为了说明它们之间没有冲突,我的理解是以前的优秀插件里面使用了1.0,但是1.0的问题确实有,所以2.0把meta改成metadata 这样就不会相互冲突了-->

8.<script type="text/javascript" src="jquery.metadata.2.0/jquery.metadata.2.0/jquery.metadata.js"></script>

9.<script type="text/javascript" src="jquery.metadata.1.0/jquery.metadata.1.0/jquery.metadata.js"></script>

10.<script language="javascript">

11. $(document).ready(function(){

12.alert($(".media").metadata().src)

13.alert($('li.someclass').metadata().some)

14.})

15.

16.</script>

17.</head>

18.

19.<body>

20.

21.<OBJECT class="media {src:'/tems/upload/192168.mp3'}" data="[object Object]"></OBJECT>

22.<li class="someclass {some: 'data'} anotherclass">...</li>

23.OR

24.<li data="{some:'random', json: 'data'}">...</li>

25.OR

26.<li><script type="data">{some:"json",data:true}</script>...</li>

27.<script language="javascript">

28.var data = $('li.someclass').metadata()

29.if ( data.some &&data.some == 'data' )

30.alert('It Worked!')

31.</script>

32.</body>

33.</html>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />

<title></title>

<script type="text/javascript" src="jquery.metadata.2.0/jquery.metadata.2.0/test/jquery.js"></script>

<!-- 这里既引用了1.0又引用了2.0,就是为了说明它们之间没有冲突,我的理解是以前的优秀插件里面使用了1.0,但是1.0的问题确实有,所以2.0把meta改成metadata 这样就不会相互冲突了-->

<script type="text/javascript" src="jquery.metadata.2.0/jquery.metadata.2.0/jquery.metadata.js"></script>

<script type="text/javascript" src="jquery.metadata.1.0/jquery.metadata.1.0/jquery.metadata.js"></script>

<script language="javascript">

$(document).ready(function(){

alert($(".media").metadata().src)

alert($('li.someclass').metadata().some)

})

</script>

</head>

<body>

<OBJECT class="media {src:'/tems/upload/192168.mp3'}" data="[object Object]"></OBJECT>

<li class="someclass {some: 'data'} anotherclass">...</li>

OR

<li data="{some:'random', json: 'data'}">...</li>

OR

<li><script type="data">{some:"json",data:true}</script>...</li>

<script language="javascript">

var data = $('li.someclass').metadata()

if ( data.some &&data.some == 'data' )

alert('It Worked!')

</script>

</body>

</html>

翻译:

attr:内部属性,参数名字指向属性名

class:内部类的属性,用{}包裹

elem:内部子元素 (如script标签).参数的名字指向元素名。

函数:

metadata( options ) Returns: Object

Extracts, caches, and returns metadata from the first element in the jQuery collection.

Arguments:

options (Optional) Options

A set of key/value pairs that define the type of metadata to be extracted. All options are optional.

Options:

metadata( options )中的options有三种:type、name、single

type String Default: 'class'

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.

Searches for metadata in a custom element attribute instead of in the class.

Javascript代码

1.$(".selector").metadata({

2. type: 'attr'

3.})

$(".selector").metadata({

type: 'attr'

})

name String Default: 'metadata'

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.

Searches for metadata in a custom element attribute with a name of 'jdata'.

Javascript代码

1.$(".selector").metadata({

2. type: 'attr',

3. name: 'jdata'

4.})

$(".selector").metadata({

type: 'attr',

name: 'jdata'

})

single String Default: 'metadata'

The name given to the data extracted from the element in the jQuery cache.

Stores and retrieves the data extracted into an item named 'jdata' in the jQuery cache.

Javascript代码

1.$(".selector").metadata({

2. single: 'jdata'

3.})

$(".selector").metadata({

single: 'jdata'

})

Examples:

Gets metadata from the class attribute.

Javascript代码

1.<li class="someclass {some: 'data'} anotherclass">...</li>

2.

3.<script>alert($('li.someclass').metadata().some)</script>

<li class="someclass {some: 'data'} anotherclass">...</li>

<script>alert($('li.someclass').metadata().some)</script>

Gets metadata from a custom attribute.

Javascript代码

1.<li data="{some:'random', json: 'data'}">...</li>

2.<script>alert($('li.someclass').metadata({type:'attr',name:'data'}).some)</script>

<li data="{some:'random', json: 'data'}">...</li>

<script>alert($('li.someclass').metadata({type:'attr',name:'data'}).some)</script>

Gets metadata from a child element.

Javascript代码

1.<li class="someclass"><script type="application/json">{some:"json",data:true}</script>...</li>

2.<script>alert($('li.someclass').metadata({type:'elem',name:'script'}).some)</script>

<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 following metadata requests.

Arguments:

type String

Specify the expected location of metadata for the element. Possible values are 'class' (default): 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.

name String

The name of the tag or attribute for which to search depending on the value of the 'type' option.

Examples:

* Code

Setup metadata plugin to look for a custom attribute.

Javascript代码

1.<li data="{some:'random', json: 'data'}" class="someclass">...</li>

2.

3.<script>

4.$.metadata.setType('attr','data')

5.alert($('li.someclass').metadata().some)

6.</script>

<li data="{some:'random', json: 'data'}" class="someclass">...</li>

<script>

$.metadata.setType('attr','data')

alert($('li.someclass').metadata().some)

</script>

jQuery.metadata.get( elem, options ) Returns: Object

Sets the default type and name options for all following metadata requests.

Arguments:

elem Element

The element containing the metadata to be extracted.

options (Optional) Options

A set of key/value pairs that define the type of metadata to be extracted. All options are optional. See the metadata plugin page for more information.

Examples:

* Code

Setup metadata plugin to look for a custom attribute.

Javascript代码

1.<li class="someclass {some:'random', json: 'data'}">...</li>

2.

3.<script>

4.$('li.someclass').each(function(){

5.var data = $.metadata.get(this)

6.alert(data.some)

7.})

8.</script>

<li class="someclass {some:'random', json: 'data'}">...</li>

<script>

$('li.someclass').each(function(){

var data = $.metadata.get(this)

alert(data.some)

})

</script>

先按照平常软件的安装方法安装,记住你的安装目录,下面说下破解

破解步骤:

0:运行 run.bat

1. 输入Usercode, 点击'SystemId...', 生成SystemId

2. 点击'Active', 生成LICENSE_KEY, ACTIVATION_CODE, ACTIVATION_KEY

3. 点击菜单'Tools ->2.SaveProperties...',

4. 点击菜单'Tools ->1.ReplaceJarFile', 选择${eclipse_home}/plugins目录, 等待30秒左右.

说明:${eclipse_home}/plugins是eclipse安装目录下有个pugins文件夹,,如果没有,在common下的plugins下.

执行以上4个步骤,破解成功.

使用metadata方式 这个需要使用jquery.metadata.js插件才可工作,通过在表单项中定义特殊的属性来指定验证规则 但是我发现最新的jquery.validate 1.11竟然没有内置metadata的支持,故需要对其进行一些改造 搜索jquery.validate.js文件中的$.vali...