Jeremiah Hubilla
Jeremiah Hubilla

Reputation: 1

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.

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? And please help me on how I will do it.

Upvotes: 0

Views: 944

Answers (2)

kapil
kapil

Reputation: 162

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>

Upvotes: 0

Prasath Albert
Prasath Albert

Reputation: 1457

You can use JQUERY tabs for achieve this one..

Please look at http://jqueryui.com/tabs/

Upvotes: 1

Related Questions