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 :

  1. get html of page , store in variable 'content'
  2. replace word in 'content' variable through regex (updated_content = content.replace(/delivery/ig,'pickup'));
  3. 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

Popular posts from this blog

qt - QML MouseArea onWheel event not working properly when inside QML Scrollview -

java - is not an enclosing class / new Intent Cannot Resolve Constructor -

python - Error importing VideoFileClip from moviepy : AttributeError: 'PermissionError' object has no attribute 'message' -