我試圖讓有itemprop="url"
所有href
值,內部main
格獲取itemprop的href的值與jQuery
HTML:
<div id="main">
<div class="list_item odd" itemscope="" itemtype="http://schema.org/Movie">
<div class="overview-top">
<h4 itemprop="name"><a href="example.com/hello1" itemprop="url"> Hello 1</a></h4>
</div>
</div>
<div class="list_item even" itemscope="" itemtype="http://schema.org/Movie">
<div class="overview-top">
<h4 itemprop="name"><a href="example.com/hello2" itemprop="url"> Hello 2</a></h4>
</div>
</div>
</div>
JQuery的:
$(('meta[itemprop="url"]'), '#main').each(function(){
var url = $(this).attr('href');
console.log (url);
});