[英]Changing a displayed <div> with another <div> when a link was clicked using php
I would like to ask some help on this thing. 我想在这件事上寻求帮助。 I created a site that has a lot of div and what I want is that when a link is clicked only one div will be displayed without reloading the whole page.
我创建了一个包含很多div的网站,我想要的是单击链接时仅显示一个div,而无需重新加载整个页面。
Sample code: 样例代码:
<ul>
<li><a href="">Div 1</a></li>
<li><a href="">Div 2</a></li>
<li><a href="">Div 3</a></li>
</ul>
<div id="content1">
<p>This is content 1</p>
</div>
<div id="content2">
<p>This is content 2</p>
</div>
<div id="content3">
<p>This is content 13</p>
</div>
Is it possible if I'll just use php? 我可以只使用php吗? And please help me on how I will do it.
并请帮助我如何做。
You can use JQUERY tabs for achieve this one.. 您可以使用JQUERY选项卡来实现这一目标。
Please look at http://jqueryui.com/tabs/ 请查看http://jqueryui.com/tabs/
Please check with below scripts 请检查以下脚本
<a href="" onclick="showdiv('content1'); ">Div 1</a>
<a href="" onclick="showdiv('content2'); ">Div 2</a>
<a href="" onclick="showdiv('content3'); ">Div 3</a>
<scripts>
var hidediv = null;
function showdiv(id) {
if(hidediv)
hidediv();
var div = document.getElementById(id);
div.style.display = 'block';
hidediv = function () { div.style.display = 'none'; };
}
</scripts>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.