jquery - Issue with toggle -


i have following code

html

<div class="menu_head"> <p class="menu_head_open"> <img style="vertical-align:middle;" src="http://oi44.tinypic.com/dyz2r.jpg" alt="">administration </p> </div> <div class="menu_body" style="display: none;">     <table class="plan_table" cellspacing="0" cellpadding="0">     <tbody>       <tr>         <td class="plan_ta_txt" style="width:40%">moderators</td>         <td>1</td>         <td>1</td>         <td style="width:10%">3 </td>         <td style="width:10%">5 </td>         <td style="width:10%">10 </td>         <td style="width:10%;border-right:none;">         <img style="width:20px; height:17px; padding-left:5px" src="right.gif" alt="right">         </td>       </tr>       <tr>         <td class="plan_ta_txt">         workflow management<br>(deparments, divisions, teams)         </td>         <td> </td>         <td> </td>         <td> </td>         <td>1</td>         <td>1</td>         <td style="border-right:none;">         <img style="width:20px; height:17px; padding-left:5px" src="right.gif" alt="right">         </td>       </tr>     </tbody>     </table> </div>  <!-- view , close buttons --> <p style="padding-top:13px;padding-left:180px;">     <a id="view_but" href="#">        <img height="31" alt="view all" style="width:87px" src="http://oi40.tinypic.com/30tlytu.jpg">     </a>     <a id="close_but" href="#">         <img height="31" alt="closeall" style="width:87px" src="http://oi43.tinypic.com/5yi0bc.jpg">     </a> </p> 

css

.menu_head{    border-bottom: 1px solid #ababab;    cursor: pointer;    font-size: 15px;    font-weight: bold;    height: 38px;    padding: 10px 18px 0;    position: relative;    background:#e4e4e4 url('http://oi41.tinypic.com/5ofhwg.jpg') center left repeat-x scroll; }  .menu_head_close{    background:#e4e4e4 url('http://oi41.tinypic.com/34fifye.jpg') center left repeat-x scroll; } 

jquery

$(document).ready(function () {     $(".menu_head").click(function () {         $(this).toggleclass('menu_head_close');         $(this).next().toggle(1000);     });     $("#view_but").click(function () {         $(".menu_body").toggle(1000);         $(".menu_head").toggleclass("menu_head_close");      });     $("#close_but").click(function () {         $(".menu_body").toggle(1000);         $(".menu_head").toggleclass("menu_head_close");     }); }); 

here have

  1. a tab, if click on it expand , displays table. have 8 similar tabs different tables.
  2. i used toggle in order toggle display shown in above code.
  3. i have view , close buttons, on click want display tables in tabs. used same toggle achieve this. , close button must close.
  4. since used toggle toggling. when table open , click view table closing since used toggle.

can 1 resolve problem?

you can use show/hide in order open or close content instead of toggle, , addclass, removeclass accordingly

$("#view_but").click(function(){     $(".menu_body").show(1000);     $(".menu_head").addclass("menu_head_close");      }); $("#close_but").click(function(){     $(".menu_body").hide(1000);     $(".menu_head").removeclass("menu_head_close");  }); }); 

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

How to call a javascript function after the page loads with a chrome extension? -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -