单击时显示和隐藏元素

时间:2015-10-11 11:52:45

标签: jquery

我想隐藏第一行并显示/显示第二行。 因此,当我点击“clearReminder”时,它将消失第一张图像,下面的图像(第二行)将会出现。

<a href="#" class="clearReminder" commentID="94"><img src="images/reminder-<?PHP echo $reminder_icon ?>.png" /></a>
<img src="images/reminder-off.png" style="display: none" class="reminder-off" commentID="94" />

<a href="#" class="clearReminder" commentID="95"><img src="images/reminder-<?PHP echo $reminder_icon ?>.png" /></a>
<img src="images/reminder-off.png" style="display: none" class="reminder-off" commentID="95" />

AJAX:

 $.ajax({
    type: "POST",
    url: "ajax/clearReminder.php",
    data: info,
    success: function(data){
    $("#loading").ajaxComplete(function()
    {
    }).slideUp();

    if (data == "true")
    {
        $('.clearReminder commentID'+commentID).fadeOut(200).hide();
        $('.reminder-off commentID'+commentID).fadeIn(200).show();
    }
   }
 });

1 个答案:

答案 0 :(得分:0)

//Calling this on click of a tags element
$(".clearReminder").click(function(el){
  //Hiding All the images 
  $(".clearReminder img").hide();

  //Now Only Showing you the image which is children of the clicked a tag
  $(this).children().show();
})