user1310420
user1310420

Reputation:

Jquery slidedown hidden element onclick

i have a hmtl structure like this that repeats an indefinite amount of times

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

Is there any way to only show the rrshow in the parent of the rrclk that was clicked? So that if you clicked one rrclk only the rrshow that was in the same rr would be shown, if that makes any sense.

Thanks

EDIT:

Thanks, is there any way i could do the same thing with AJAX, like this:

$('.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");
        }
    });

Upvotes: 1

Views: 1180

Answers (5)

palerdot
palerdot

Reputation: 7642

$('.rrclk').click(function(){
$(this).siblings('.rrshow').show();
});

you could use this jquery, if I understand you correctly,

Here is a JSFIDDLE http://jsfiddle.net/fb4gr/

Upvotes: 0

user1306004
user1306004

Reputation:

By using jQuery show() and hide() methods you can fix this, first set an id to the 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
});

Upvotes: 0

alphakevin
alphakevin

Reputation: 544

$('.rr .rrclk').click(function(){
   $(this).siblings('.rrshow').toggle();
});

Upvotes: 0

Uttara
Uttara

Reputation: 2534

Hope this is what you want

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

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

here is a demo

Upvotes: 2

user1043994
user1043994

Reputation:

$('.rrclk').click(function() {
    $(this).next().show();
});

Upvotes: 0

Related Questions