S
Sally B.
Hi, how would I go about doing the following: substitute all the
strings 'the' and 'dog' in the 'mytext' id div only? The following
doesn't work for 'the'. I also need to use regular expressions for the
replace command... but I can't get that far. Any reason this doesn't
work as below:
<script>
function start() {
theText=document.getElementById('mytext');
theText.replace(/the/g, "xxxx");
}
</script>
</head>
<body onload="start()">
<p>the quick brown fox jumps over the lazy dog</p>
<div id=mytext>the quick brown fox jumps over the lazy dog</div>
</body>
</html>
I have researched a bit and all the 'replace' examples I think should
work, don't. Also, is this even the best way to do it? If I have a big
chunk of text in a <div>, what would be a better way to search and
replace with regular expressions?
Thanks!
Sally-B
strings 'the' and 'dog' in the 'mytext' id div only? The following
doesn't work for 'the'. I also need to use regular expressions for the
replace command... but I can't get that far. Any reason this doesn't
work as below:
<script>
function start() {
theText=document.getElementById('mytext');
theText.replace(/the/g, "xxxx");
}
</script>
</head>
<body onload="start()">
<p>the quick brown fox jumps over the lazy dog</p>
<div id=mytext>the quick brown fox jumps over the lazy dog</div>
</body>
</html>
I have researched a bit and all the 'replace' examples I think should
work, don't. Also, is this even the best way to do it? If I have a big
chunk of text in a <div>, what would be a better way to search and
replace with regular expressions?
Thanks!
Sally-B