2016-08-25 6 views
1

他のボタンが表示されているときにjQueryを使用してボタンを表示しようとしています。しかし、私はjQueryの専門家ではありません。だから私はこれで私を助けることができる誰かがいるのだろうかと思っていたのですか?ボタンBが表示されているときにのみボタンAを表示する

私は2つのボタンがあります:ボタンdel-stepが画面に表示されているときに私が何をしたいのか

  • ボタンent-step
  • ボタンdel-step

は唯一のショーボタンent-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は、Ajaxによって呼び出された他の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-ステップが表示されない.ent-stepボタンを隠すことができます'あなたのコードで。 – eisbehr

+0

$( "del-step [data-location = '" + dataLocation + "']")の直後です。あなたは$( "。ent-step")のような** ent-step **を表示できます。 –

答えて

1

非表示.add-step

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

そして、あなたは.add-stepを隠しているのclassに基づいてボタンが同様に

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

ありがとうございました! – Steggie

関連する問題