javascript - Replace multiple occurrences of words in html of page -
how can replace words in html without losing event bindings ?
i want replace occurrences of word 'delivery' 'pickup' on html page
suggested approaches :
- get html of page , store in variable 'content'
- replace word in 'content' variable through regex (updated_content = content.replace(/delivery/ig,'pickup'));
- update page html updated_content
but approach wipes out event binding on page
if use jquery:
$("*:not(html, table, tbody, tr):contains('" + yoursearchphrase + "')").each(function(index, item) { item.innertext = item.innertext.replace(yoursearchphrase, replacementtext); });
Comments
Post a Comment