简体   繁体   中英

Changing font icon(font awesome) does not work in IE

I have a sliding pane in my html. I am using an icon that is pointing left to show that the pane is collapsible. As soon as the user clicks the icon, I want to collapse the window and change the icon so it is pointing to right to show that it is expandable. My code works fine in chrome but the icon does not point to right after the click in IE. I am currently using IE 11. Any ideas on how I can fix this?

    <div class="openClose" id="openClose">
        <div class="leftPanelClose">
            <a href="javascript:collapseExpand()"><i class="fa fa-angle-double-left" id="icon"</i></a>
        </div>
    </div>

function collapseExpand(){
    var ic = document.getElementById("icon");

    if (left.style.display=="block")
    {
    /*collapse pane*/
    ic.classList.remove("class", "fa-angle-double-left");
    ic.classList.add("class", "fa-angle-double-right");
    }
    else
    {
    /*expand pane*/
    ic.classList.remove("class", "fa-angle-double-right");
    ic.classList.add("class", "fa-angle-double-left");
    }
}

Did not need "class" argument when adding or removing classes from the icon.

    <div class="openClose" id="openClose">
        <div class="leftPanelClose">
            <a href="javascript:collapseExpand()"><i class="fa fa-angle-double-left" id="icon"</i></a>
        </div>
    </div>

function collapseExpand(){
    var ic = document.getElementById("icon");

    if (left.style.display=="block")
    {
    /*collapse pane*/
    ic.classList.remove("fa-angle-double-left");
    ic.classList.add("fa-angle-double-right");
    }
    else
    {
    /*expand pane*/
    ic.classList.remove("fa-angle-double-right");
    ic.classList.add("fa-angle-double-left");
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM