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 : ►
change in 1 :▲
, clues ?
thanks in advance !
wrap speacial html character ►
<span>
tag:
<a onclick="toggle(this, 'node1')"><span>►</span> title01 </a>
then can change ▲
after showing hidden element , ►
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 = '▲'; } else { e.style.display = 'none'; a.innerhtml = '►'; } }