javascript - Html change part of the label text -
i have following javascript code:
window.toggle = function() { if( document.getelementbyid("calendar").style.display=='none' ){ document.getelementbyid("calendar").style.display = ''; $(".icon-chevron-down").removeclass("icon-chevron-down").addclass("icon-chevron-up"); document.getelementbyid("label").innertext = "hide calendar"; } else { document.getelementbyid("calendar").style.display = 'none'; $(".icon-chevron-up").removeclass("icon-chevron-up").addclass("icon-chevron-down"); document.getelementbyid("label").innertext = "show calendar"; } }
i change part of label, because wouldn't remove bootstrap icons. here: http://jsfiddle.net/rkaqd/2/
have hints how cope disappering bootstrap icons?
edit:
maybe write example have:
v 'show calendar'
^ 'hide calendar'
v 'show calendar'
^ 'hide calendar'
and on...
the problem facing because changing inner text of element id label.... label has 2 icon elements inside besides text.
what did putting text "hide calendar" , "show calendar" span id , changing inner text of span ( not label ) instead of having:
<i class="icon-chevron-down"></i> show calendar <i class="icon-calendar"></i>
you must have
<i class="icon-chevron-down"></i> <span id="display_text">show calendar</span> <i class="icon-calendar"></i>
and change 2 lines on javascript from
document.getelementbyid("label").innertext = "hide calendar"; document.getelementbyid("label").innertext = "show calendar";
to
document.getelementbyid("display_text").innertext = "hide calendar"; document.getelementbyid("display_text").innertext = "show calendar";
hope helped.
Comments
Post a Comment