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

WBOY
Release: 2016-06-06 20:07:38
Original
1106 people have browsed it

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

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

回复内容:

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

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

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

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

不过,这种方式真心很矬

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

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template