1

私は無期限に繰り返すこのような hmtl 構造を持っています

 <div class='rr'>
  <div class='rrclk'>
   Click Me
  </div>
  <div class='rrshow'>
    I am now shown
   </div>

クリックされた rrclk の親でのみ rrshow を表示する方法はありますか? そのため、1 つの rrclk をクリックすると、同じ rr にある rrshow のみが表示されます。

ありがとう

編集:

ありがとう、次のように、AJAXで同じことを行う方法はありますか:

$('.rrclk').click(function () {
    $.ajax({
        type: "POST",
        url: 'getdata.php',
        data: {
            uid: this.id
        },
        success: function (data) {
   $(this).parent().find(".rrshow").html(data);
   $(this).parent().find(".rrshow").fadeToggle("fast");
        }
    });
4

5 に答える 5

2

これがあなたが望むものであることを願っています

$(".rrclk").click(function(){
   //hide all rrshow
   $(".rrshow").hide();

   //show only required rrshow
   $(this).parent().find(".rrshow").show();
});

ここにデモがあります

于 2012-08-11T06:58:53.953 に答える
0
$('.rrclk').click(function(){
$(this).siblings('.rrshow').show();
});

私があなたを正しく理解していれば、あなたはこのjqueryを使うことができます。

ここにJSFIDDLEがありますhttp://jsfiddle.net/fb4gr/

</p>

于 2012-08-11T07:03:52.293 に答える
0
$('.rrclk').click(function() {
    $(this).next().show();
});
于 2012-08-11T06:58:22.643 に答える
0
$('.rr .rrclk').click(function(){
   $(this).siblings('.rrshow').toggle();
});
于 2012-08-11T07:00:19.733 に答える
0

jQuery の show() および hide() メソッドを使用すると、これを修正できます。最初に id を div に設定します。

$("# place rrshow id here").show();
$("# place rrshow id here").hide();


$("#place rrclk id here").click(function(){
//$("# place rrshow id here").show(); or $("# place rrshow id here").hide(); whatever you want
});
于 2012-08-11T07:03:19.050 に答える