如何在javascript中更改字形图标文本 显示搜索条件 如果(blnShowFilter=='false'){ document.getElementById('glyphBtn')。className='glyphicons-glyphicons-减号'; } 否则{ document.getElementById('glyphBtn')。className='glyphicons glyphicons plus'; }

如何在javascript中更改字形图标文本 显示搜索条件 如果(blnShowFilter=='false'){ document.getElementById('glyphBtn')。className='glyphicons-glyphicons-减号'; } 否则{ document.getElementById('glyphBtn')。className='glyphicons glyphicons plus'; },javascript,glyphicons,linkbutton,Javascript,Glyphicons,Linkbutton,我已经能够更改实际的glyphicon本身,但我正在努力获取链接按钮内部但超出范围的文本。文本“显示搜索条件”我希望在单击按钮后将其更改为“隐藏搜索条件”,有什么想法吗?if(blnShowFilter==“false”) <asp:LinkButton CssClass="btn btn-default search" runat="server" ID="ShowHide" OnClientClick="return false;" title="Hide Search">&l

我已经能够更改实际的glyphicon本身,但我正在努力获取链接按钮内部但超出范围的文本。文本“显示搜索条件”我希望在单击按钮后将其更改为“隐藏搜索条件”,有什么想法吗?

if(blnShowFilter==“false”)
<asp:LinkButton CssClass="btn btn-default search" runat="server" ID="ShowHide" 
OnClientClick="return false;" title="Hide Search"><span id="glyphBtn" 
class="glyphicons glyphicons-plus"></span>Show Search Criteria</asp:LinkButton>

if (blnShowFilter == 'false') {
            document.getElementById('glyphBtn').className = 'glyphicons glyphicons-minus';
        }
        else {
            document.getElementById('glyphBtn').className = 'glyphicons glyphicons-plus';
        }
document.getElementById('ShowHide').innerHTML='Hide搜索条件'; 其他的 document.getElementById('ShowHide').innerHTML='Show Search Criteria';

与更改
glyphicon
的类不同,使用
更新文本和
glyphicon

的新类更改
innerHTML
ShowHide
按钮,您可能需要使用作为asp链接的客户端idbutton@Pete我不明白。请解释。根据您的设置,当呈现asp按钮时,id有时会更改以包含额外的控件信息,以确保其唯一性,因此
ShowHide
可能不是最终的id@Pete哦,好吧,明白了。这是一个更好的方法。在本例中,它似乎在不使用ClientID的情况下工作,谢谢。
if (blnShowFilter == 'false') 
    document.getElementById('ShowHide').innerHTML = '<span id="glyphBtn" class="glyphicons glyphicons-minus"></span>Hide Search Criteria';
else 
    document.getElementById('ShowHide').innerHTML = '<span id="glyphBtn" class="glyphicons glyphicons-plus"></span>Show Search Criteria';