Reputation:
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
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
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
Reputation: 544
$('.rr .rrclk').click(function(){
$(this).siblings('.rrshow').toggle();
});
Upvotes: 0