2016-08-25 118 views
1

我试图在显示其他按钮时使用jQuery显示按钮。但我不是一个jQuery专家。所以我想知道是否有人能帮助我解决这个问题?仅当显示按钮B时才显示按钮-A

我有2个按钮:

  • 按钮ent-step
  • 按钮del-step

我想要做的是只显示按钮ent-step当按钮del-step在屏幕上。通常情况下这个按钮del-step隐藏与这个JavaScript:

function showDellocation($this) { 
    var dataLocation = $this.attr("data-location"); 
     $(".del-step[data-location='" + dataLocation + "']").show(); 
     $(".add-step[data-location='" + dataLocation + "']").addClass("blur"); 
    } 
function hideDellocation($this) { 
    var dataLocation = $this.attr("data-location"); 
     $this.hide(); 
     $(".add-step[data-location='" + dataLocation + "']").removeClass("blur"); 
} 

按钮ent-step是阿贾克斯称为其他PHP文件:

<table class="item-buttons"> 
    <tr> 
     <td style="width:150px;">&nbsp;</td> 
     <td style="width:150px;"> 
      <a href="example.com/step" value="Ent"> 
       <button class="ent-step">Entertainment&nbsp; 
        <i class="fa fa-angle-double-right" aria-hidden="true">/i> 
       </button> 
      </a> 
     </td> 
    </tr> 
</table> 

我可以使用blur类来激活这个选项?例如:

jQuery(document).ready(function($) { 
    if ($(this).hasClass('blur')) { 
     $('.ent-step').addClass('clickable'); 
    } 

然后使用CSS风格的按钮? 或者这不是正确的方法吗?

+0

我不明白'ENT一步按钮'在你的代码中。 – eisbehr

+0

$(“。del-step [data-location ='”+ dataLocation +“']”)。show();你可以显示** ent-step **,像$(“。ent-step”)。show(); –

回答

1

您可以显示隐藏的基础上.add-step

if ($('.add-step').hasClass('blur')) { 
    $('.ent-step').show(); 
} 

class当你都躲在.add-step隐藏.ent-step按钮以及

function hideDellocation($this) { 
    var dataLocation = $this.attr("data-location"); 
    $this.hide(); 
    $(".add-step[data-location='" + dataLocation + "']").removeClass("blur"); 
    $('.ent-step').hide(); 
} 
+0

谢谢你的魅力! – Steggie