0

i need some help to make a button for enable or disable 2 div with jquery. i have 2 kind of navigation code in my page. these are my codes:

First:

<div class="nextprev">
[prev-link]Previous[/prev-link]
[next-link]Next[/next-link]
</div>

Second:

<div id="page_navigation1" class="page_navigation1">[next-link]Next[/next-link]</div>

Now, i need some jquery code for enable or disable these div's. for example, when we click on enable button just first div will be working and when we click on disable, just second div will be working!

i hope u guys undrstand my question and im sorry for my bad english.

4

1 回答 1

0

toggle() 函数切换 div 的可见性。所以也许是这样的?

http://jsfiddle.net/UvWEu/17/

<script type="text/javascript">
    function toggleDivs() {
        $("#nav1").toggle();
        $("#nav2").toggle();
    }
</script>


<div id="nav1" 
     style="background-color:red;width:50px;height:50px;display:none;">nav1
</div>
<div id="nav2" 
     style="background-color:green;width:50px; height:50px;display:visible;">nav2
</div>
<button text="toggle" style="width:50px; height=18px" onclick="toggleDivs();" />​
于 2012-07-15T01:35:14.800 回答