如何更改 javascript 中的字形文本
How to change a glyphicons text in javascript
<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';
}
我已经能够更改实际的字形图标本身,但我很难找到 link 按钮内但跨度外的文本。文本 'Show Search Criteria' 我希望在单击按钮后将其更改为 'Hide Search Criteria',有什么想法吗?
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';
不要更改 glyphicon
的 class,而是将 #ShowHide
按钮的 innerHTML
更改为 glyphicon
updated text and new class
<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';
}
我已经能够更改实际的字形图标本身,但我很难找到 link 按钮内但跨度外的文本。文本 'Show Search Criteria' 我希望在单击按钮后将其更改为 'Hide Search Criteria',有什么想法吗?
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';
不要更改 glyphicon
的 class,而是将 #ShowHide
按钮的 innerHTML
更改为 glyphicon
updated text and new class