如果我想從列表中的href中獲取日期(例如:2016-12-21),您將如何去做這件事?再取該值,並將其放置在<li>
使用jQuery獲取href路徑的一部分
<ul id="xdesc" class="">
<li class="">
2016-12-21
<div class="">
<a class="hs-rss-title" href="http://domain.com/events/womens-event-2016-12-21?__hstc=233546881.1c39d8c7bec9e076de1b637bf5317294.1475698351504.1477050663648.1477054875380.25&__hssc=233546881.1.1477054875380&__hsfp=1945213963"><span>Event 2 Women's Event</span></a>
</div>
</li>
<li class="hs-rss-item">
2016-03-21
<div class="hs-rss-item-text">
<a class="hs-rss-title" href="http://domain.com/events/mens-event-2016-03-21?__hstc=233546881.1c39d8c7bec9e076de1b637bf5317294.1475698351504.1477050663648.1477054875380.25&__hssc=233546881.1.1477054875380&__hsfp=1945213963"><span>Event 1 Men's Event</span></a>
</div>
</li>
</ul>
寬度的正則表達式。 – vaso123
'href.split('name-event - ')。pop()。split('?')。shift()' – adeneo
[Extract部分字符串]可能重複(http://stackoverflow.com/questions/18290599/extract-part-of-the-string) – DaniP