我在守则中看到了一个ug:
www.un.org/spanish/ecosoc 该法典用一个突出版本取代某些常规案文:。
var param = getCurrentParam();
var text = document.getElementById("mydiv").innerHTML;
document.getElementById("mydiv").innerHTML = text .replace(param, <span style="background-color:yellow;"> +param+ </span> );
www.un.org/spanish/ecosoc 但是,在这一案例中,这赢得了工作:。
param = my text more text another line here ;
<>Real>html:
my text more text
another line here
Because there is a line break (no br, just enter key in the text editor), the param has just white space, but in reality (in the html) the text had something (i guess as such):
;
So the replace wont work, because there is probably a: "
" but it searches instead for a " ";
How can I fix my replace method?