有html如下
<div  class="left_menu_tab"> 
  <h4>asdfasdf</h4>
  <div style="display:inline">
    <li> <a href="http://www.qq.com" target="contents">asdf</a></li>
    <li> <a href="#">asdf</a> </li>
    <li> <a href="#">asdf</a> </li>
    <li> <a href="#">asdf</a> </li>
  </div>
</div>div中没有ID,我想实现单击h4标签即可隐藏h4标签下面的div,不是隐藏所有的div
部分JS如下function showLeftMenu() {
$(".left_menu_tab>h4").click(function () {

if (。。.style.display == "none") {
。。.style.display = "inline";
 
} else {
。style.display = "none";
 
}
});
}

解决方案 »

  1.   

    function showLeftMenu() { 
    $(".left_menu_tab>h4").click(function () { 
    var div=$(".left_menu_tab>h4 +div")
    //或者var div=$(this).parentNode.getElementsByTagName('div')[0];
    if (div.style.display == "none") { 
    div.style.display = "inline"; } else { 
    div.style.display = "none"; } 
    }); 
    }
      

  2.   

    下次记得给分!!!
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <title>Untitled Document</title>
            <script type="text/javascript" src="jquery-1.3.2.js">
            </script>
            <script type="text/javascript">
                /**
                 * @author develop_design_level
                 * date 2009-11-06
                 */
                $(function(){
                    $('h4').click(function(){
    $('h4 + div').hide();
    });
                });
            </script>
        </head>
        <body>
    <div  class="left_menu_tab"> 
      <h4>asdfasdf </h4> 
      <div style="display:inline"> 
        <li> <a href="http://www.qq.com" target="contents">asdf </a> </li> 
        <li> <a href="#">asdf </a> </li> 
        <li> <a href="#">asdf </a> </li> 
        <li> <a href="#">asdf </a> </li> 
      </div> 
    </div> 
        </body>
    </html>
      

  3.   

        <script type="text/javascript">
            function f() {
                $("div")[1].innerHTML = 1; 
                }
                
        </script>
    </head>
    <body onload='f()'> <div>2</div>
    <div></div>
    </body>
      

  4.   

    下次记得给分!!! 
    $("h4").click(function(){$(this).next().hide()});
      

  5.   

    如果当隐藏的时候也要单击显示,可以写成这样:$("h4").each(function(){
               $(this).click(function(){
                  if($(this).next().css("display")=="none");
                       $(this).next().show();
                  else
                      $(this).next().hide();
                   });
    });