Can't figure out how to fix a word replace javascript -
i want change words on page below script. m not sure how fix ... can help?
http://jsfiddle.net/cip691/yums7/
var dict = { "not": " not ", "is not": " not ", "like": " likeeee ", "like": "lllike", "job": "job" }, terms = [], term; (term in dict) { terms.push(term); var search = new regexp('\\b(' + terms.join('|') + ')\\b', 'g'); }; // every text node: textnode.data = textnode.data.replace(search, function(full, match) { return dict[match] || match; });
you should define textnode
like in example
<head> <script type="text/javascript"> function gettextnode () { var textcontainer = document.getelementbyid ("textcontainer"); var textnode = textcontainer.firstchild; alert (textnode.data); } </script> </head> <body> <div id="textcontainer">this simple text in container.</div> <button onclick="gettextnode ()">get contents of container</button> </body>
Comments
Post a Comment