1

我有一个这样的 hmtl 结构,可以无限重复

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

有没有办法只在被点击的 rrclk 的父级中显示 rrshow ?因此,如果您单击一个 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).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() 方法,您可以解决此问题,首先为 div 设置一个 id

$("# 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 回答
0
$('.rrclk').click(function(){
$(this).siblings('.rrshow').show();
});

如果我理解正确,你可以使用这个 jquery,

这是一个 JSFIDDLE http://jsfiddle.net/fb4gr/

​</p>

于 2012-08-11T07:03:52.293 回答