根据状态更改bootstrap glyphicon

时间:2016-10-21 06:52:33

标签: javascript html css twitter-bootstrap knockout.js

我试图根据$context = stream(); stream($context, array('user_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6\r\n')); file_get_html('http://www.t-mobile.com/shop/phones/cell-phone-detail.aspx?cell-phone=HTC-One-S- Gradient-Blue&tab=reviews#BVRRWidgetID', 0, $context); 更改我的字形,但没有出现任何字形。我做错了什么?

HTML代码:

StatusLineId

Js功能

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

2 个答案:

答案 0 :(得分: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/

答案 1 :(得分:0)

StatusLineId既未声明也未作为参数传递给statusIcon()函数。

在函数内声明StatusLineId并尝试。它有效。