我有一个新闻页面,我希望使用跨度类“日期”按月过滤按钮。使用 list.js,我只能使用完全匹配的字符串进行过滤。是否有一个通配符可以用来显示包含单词 November 的所有项目
HTML
<button class="btn" id="filter-oct">October</button>
<button class="btn" id="filter-nov">November</button>
<div class="newsitem">
<h2>News title</h2>
<p><span class="date">Thursday 31 November 2013</span> Some text, more text</p>
<p>Should you have any concerns, require additional information or wish to discuss this matter further please contact me</p>
</div>
JS
<script type="text/javascript">
var options = {
valueNames: [ 'date' ]
};
var featureList = new List('election-list', options);
$('#filter-nov').click(function() {
featureList.filter(function(item) {
if (item.values().date == "November 2013") {
return true;
} else {
return false;
}
});
return false;
});
</script>
它在这一行进行匹配 - 但只匹配确切的单词/s
if (item.values().date == "2013 年 11 月") {
我尝试使用 &= 和 ^= 来尝试匹配,但都不起作用。
谢谢