【发布时间】:2019-04-22 22:48:43
【问题描述】:
我在两个选项卡式视图列表和网格中有内容。内容包括分页链接,其哈希值为#list 或#grid,具体取决于选项卡式视图。默认为#list。 When the tabbed view switches to grid I want to update the hash value on pagination links from #list to #grid on anchors with a class name of '.pagehash'.我如何使用 javascript/jquery 做到这一点?到目前为止,这是我所拥有的:
<a href="?{{ query }}&cfilters={{count}}&page={{ results.currentPage-1 }}#list" class="pagehash">← Prev</a>
Javascript:
$('#view-tabs').on('change.zf.tabs', function() {
$(".pagehash").attr('href').replace(/^.*?(#|$)/,location.hash); // doesn't work when tabs change from list -> grid
console.log(location.hash); // works when tabs change fom list -> grid
});
我做错了什么?非常感谢任何帮助。搜索堆栈溢出和谷歌的答案。什么都没有出现。
【问题讨论】:
标签: javascript jquery hash attributes onchange