Home  >  Article  >  Backend Development  >  dwz如何通过点击某个按钮刷新相应的navTab

dwz如何通过点击某个按钮刷新相应的navTab

WBOY
WBOYOriginal
2016-06-06 20:07:381107browse

怎样通过点击某个按钮,比如刷新 来重新加载此navTab

<code><li id="refresh"><a class="add"><span>刷新</span></a></li></code>

回复内容:

怎样通过点击某个按钮,比如刷新 来重新加载此navTab

<code><li id="refresh"><a class="add"><span>刷新</span></a></li></code>

你是要通过刷新页面的方式重新获取整个页面么?确实这种方式最简单粗暴,也能拿到最新的navTab,手法很简单:

<code class="html"><li id="refresh"><a class="add"><span>刷新</span></a></li></code>
<code class="javascript">document
.querySelector('.add')
.addEventListener('click', function(){
    window.location.reload(true);//强制刷新页面
}, false);</code>

不过,这种方式真心很矬

如果你能通过ajax异步拿到navTab用到的数据,在浏览器端重新构建一次navTabdom结构,并替换现有的久结构,实现局部刷新不是更好么?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn