Dio*_*ane 10 html javascript jquery
我正在构建一个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>
Run Code Online (Sandbox Code Playgroud)
是否有一种简单的方法可以查询纬度和经度值而无需循环遍历所有内容?
rmo*_*ero 22
你试过这个吗?
jQuery(function($){
var latitude = $('.geo meta[itemprop="latitude"]').attr("content");
var longitude = $('.geo meta[itemprop="longitude"]').attr("content");
});
Run Code Online (Sandbox Code Playgroud)