2016-10-21 9 views
0

StatusLineIdに応じてグリフコンを変更しようとしていますが、グリフコンは表示されません。私は間違って何をしていますか?ステータスに応じてブートストラップグリフコンを変更します

HTMLコード:

<div> 
    <div id="status-icon" data-bind="visible: statusIcon" style="float:left;width:30px;"> 
     <span class="glyphicon"></span> 
    </div> 
</div> 

のJS機能

function statusIcon() { 
    if (StatusLineId == 1) { 
     $("#status-icon").find(".glyphicon").addClass("glyphicon-remove"); 
    } 
    else if (StatusLineId == 11) { 
     $("#status-icon").find(".glyphicon").addClass("glyphicon-chevron-up"); 
    } 
    else { 
     $("#status-icon").find(".glyphicon").addClass("glyphicon-flash"); 
    } 
} 
+0

あなたはフィドルを投稿できますか? – arnabkaycee

答えて

0

私は、次のコードを試してみました、それが働きました。 'StatusLineId' の値を変更し、フィドルでテストしてください。

<div> 
    <div id="status-icon" data-bind="visible: statusIcon" style="float:left;width:30px;" onClick="statusIcon();">here 
     <span class="glyphicon"></span> 
    </div> 
</div> 


    $(document).ready(function() { 
var StatusLineId = 0 
    if (StatusLineId == 1) { 
    //alert('remove'); 
     $("#status-icon span").toggleClass('glyphicon-arrow-right').toggleClass('glyphicon-remove') 
} 
    else if (StatusLineId == 11) { 
     $("#status-icon span").toggleClass('glyphicon-arrow-right').toggleClass('glyphicon-chevron-up') 
} 
    else { 
     $("#status-icon span").toggleClass('glyphicon-arrow-right').toggleClass('glyphicon-flash'); 

} 

}); 

https://jsfiddle.net/tsscrpn6/

0

StatusLineIdはstatusIcon()関数のパラメータとして宣言されていないにも渡さもされていません。

関数内にStatusLineIdを宣言して試してください。できます。

関連する問題