From the above image currently 1st View Details is clicked so it is showing as Hide Details.
if i click on 3 rd View Details all 1st one or(Active one) has to be relaced to view details how can i do that..?
Here what i have tried:
Hide Details:
$("#tbodyid" ).on( "click", ".hide-details", function() {
$("#participantsForGd").hide();
var field = $(this);
field.text("View Details");
field.addClass("view-details");
field.removeClass("hide-details");
});
View-datails
$("#tbodyid" ).on( "click", ".view-details", function() {
$("#participantsForGd").show();
var field = $(this);
field.text("Hide Details");
field.addClass("hide-details");
field.removeClass("view-details");
});
My html:
<?php while($grpData = $grpQuery->fetch_assoc()){ ?>
<tr>
<td>
<span id="<?php echo $grpData['group_id'];?>" class="view-details">View Details</span>
</td>
</tr>
<?php } ?>
This one has to work like toggle:
<form id="participantsForGd" >BLAH BLAH </form>
Your html structure is not good to do this task easily. I am showing how you perform this task. Then you can modify as your need.
HTML:
JQuery: