changing HTML characters with javascript -
i have html page javascript hides , shows element given id (shown below). change single character in html text such when text hidden »
character shown , when hidden text made visible ︾
character shown (same other character, facing downwards)
what need reference element pass »
, change pass ︾
? preferably, without knowing first part of text pass
. fail
, instance.
thanks, paulh
<!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd"> <html> <head> <title></title> <script type="text/javascript"> <!-- function toggle_visibility(id) { var e = document.getelementbyid(id); if(e.style.display == 'block') { e.style.display = 'none'; } else { e.style.display = 'block'; } } //--> </script> </head> <body> <a href="#" onclick="toggle_visibility('1');"><div class="bar"><span class="foo">pass »</span><p>lorem ipsum dolor sit amet, consectetur adipisicing elit</p></div></a> <div class="baz" id="1" style='display:none;'> sed eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat </div> </body> </html>
here asked for:
http://jsfiddle.net/jtbowden/c9kym/
i added id
attribute span around pass »
easier reference.
however, others have stated, jquery makes easier. without jquery, can simplify adding spans open/close cases:
http://jsfiddle.net/jtbowden/4sblu/
this removes reliance on search/replace functionality, may or may not work special characters easily. in addition, replace these spans images.
Comments
Post a Comment