提取元数据插件Metadata

提取元数据插件Metadata
 点击下载

This plugin is capable of extracting metadata from classes, random attributes, and child elements.

For example, you can do:

  1. <li class="someclass {some: 'data'} anotherclass">...</li> 
  2. OR 
  3. <li data="{some:'random', json: 'data'}">...</li> 
  4. OR 
  5. <li><script type="data">{some:"json",data:true}</script> ...</li>  

The default is the first method, but you can always change it by twiddling the options. This means that there is at least one option here that can appease you.

After that you can simply do:

  1. var data = $('li.someclass').metadata(); 
  2. if ( data.some && data.some == 'data' ) 
  3.     alert('It Worked!'); 

There's also a bunch of options (like the ability to ignore braces {}).

For full documentation see .

 

转载请注明:代码家园 » 提取元数据插件Metadata

评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)