javascript - How can I replace a special character with an onclick? -


i found js function collapsible text.

    function toggle(id) {       var e = document.getelementbyid(id);        if (e.style.display == '')         e.style.display = 'none';       else         e.style.display = '';     }      </script> 

and here html :

► title01 text01, text01, text01, text01, text01, text01, text01, text01, text01,

what when onclick special character : &#9658; change in 1 :&#9650; , clues ?

thanks in advance !

wrap speacial html character &#9658; <span> tag:

<a onclick="toggle(this, 'node1')"><span>&#9658;</span> title01 </a> 

then can change &#9650; after showing hidden element , &#9658; when it's hidden:

function toggle(elm, id) {   var e = document.getelementbyid(id),       = elm.getelementsbytagname('span')[0];     if (e.style.display == 'none')   {     e.style.display = '';     a.innerhtml = '&#9650;';   }   else   {     e.style.display = 'none';     a.innerhtml = '&#9658;';   } } 

demo


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -