[英]How to find and read metadata using jQuery (schema.org microformat)?
我正在构建一个Google Maps应用程序,我想从我的HTML中读出schema.org指定的元数据,以绘制我的地图标记。
例如:
<li itemscope="itemscope" itemtype="http://schema.org/LocalBusiness">
...some html...
<div class="geo" itemprop="geo" itemscope="itemscope" itemtype="http://schema.org/GeoCoordinates">
<meta itemprop="latitude" content="43.681505" />
<meta itemprop="longitude" content="-79.294455" />
</div>
</li>
是否有一种简单的方法可以查询纬度和经度值而无需循环遍历所有内容?
你试过这个吗?
jQuery(function($){
var latitude = $('.geo meta[itemprop="latitude"]').attr("content");
var longitude = $('.geo meta[itemprop="longitude"]').attr("content");
});
您可以像这样获取数据:
$('meta[itemprop="latitude"]').attr('content')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.