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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -