2012-02-27 9 views
0

コードは次のとおりです。のjQuery本部コンテンツの変更クリックLIオプション

<html> 
    <div id="bigpanel"> 
    <div id="tabs"> 
    <div id="fragment-1" class="ui-tabs-panel"> </div> 
    <div id="fragment-2" class="ui-tabs-panel ui-tabs-hide"></div> 
    <div id="fragment-3" class="ui-tabs-panel ui-tabs-hide"></div> 
    <div id="fragment-4" class="ui-tabs-panel ui-tabs-hide"></div> 
    </div> 

    <div id="banerprods"> 
    <h2><a href="#"> Drinks </a> /<a href="#"> Food </a>/<a href="#"> Misc</a></h2> 
    <div id="prodsmiddle"> 
    <table width="880" border="0" cellspacing="0" cellpadding="0"> 
    <tr> 
    <td><li class="ul-buttom ul-buttom-hide"><a href="#fragment-1">1</a></li></td> 
    <td><li class="ul-buttom ul-buttom-hide"><a href="#fragment-2">2</a></li></td> 
    <td><li class="ul-buttom ul-buttom-hide"><a href="#fragment-3">3</a></li></td> 
    <td><li class="ul-buttom ul-buttom-hide"><a href="#fragment-4">4</a></li></td> 
    </tr> 
    </table> 
    </ul>  
    </div> 
    </html> 

私はすでにこれを試します

<script src="http://code.jquery.com/jquery-latest.js"></script> 
    <script> 
     $(document).ready(function(){ 
      $(".ui-tabs-panel").hide; 
      $(".ul-buttom ul-buttom-hide").click(function() { 
      var divname= this.value; 
       $("#"+divname).show("slow").siblings().hide("slow"); 
     }); 

     }); 
    </script> " 

でも作業しませんでした。 お願いします!

+0

何?何かエラーがありますか? –

答えて

0

はこれを試してみてくださいする必要がありますか?

$(document).ready(function(){ 
      $(".ui-tabs-panel").hide(); 
      $(".ul-buttom.ul-buttom-hide a").click(function() { 
       var divname= $(this).attr("href"); 
       $(divname).show("slow").siblings().hide("slow"); 
      }); 
}); 
+0

今すぐ完璧に動作するTksの男! – Lbezerra

0

.hideはおそらく.hide()

1

あなたのロジックにいくつかのミスがあった:

$(function(){ 
    $(".ui-tabs-panel").hide();//notice the parenthesis added to `hide()` 

    //the elements you want to select are the children `a` elements of the `li` elements with both the `.ul-buttom` and the `.ul-buttom-hide` classes 
    $(".ul-buttom.ul-buttom-hide").children().click(function() { 

     //since we are getting data from the `href` attribute, we target it with `.attr('href')`, 
     //`.value` is for form inputs 
     var divname = $(this).attr('href'); 

     //since the `href` attribues already have hash marks, we don't have to add any 
     $(divname).show("slow").siblings().hide("slow"); 
    }); 
});​ 

デモ:http://jsfiddle.net/jasper/XSLEw/

+0

非常に素晴らしいジャスパー、私の疑いのいくつかをクリアし、本当に良い作品! ありがとう – Lbezerra

0

まず.hide.hide()次のようになります。

リンクについては次に
$(".ui-tabs-panel").hide(); 

、あなたの場合2つのクラスを持つ要素を対象にしたい場合は、この方法で記述する必要があります、スペースなし:私はあなたがより良いだけで一つのクラスでアンカータグをターゲットと思うが

$(".ul-buttom.ul-buttom-hide") 

に十分であろう。うまくいかない

$(".ul-buttom-hide a").click(function() { 
    var divname= $(this).attr('href'); 
    $(divname).show("slow").siblings().hide("slow"); 
});​ 
関連する問題