imagine we have a variable in javascript
var html = "<html>...<img src="a"></img>...<a><img src="b"></img></a></html>"
we never know when img tag are located. We don't have any id's. They only have different src, and we know this src because we have them stored in a database.
How to write a method that will take every html content from 'html' variable defined above and change only src's there. For example if I know that src has a value 'a' then I want to invoke some method that will write there 'c' instead of an 'a' and so on . With some loop I would like to change src's only.
Any thoughts?
replace()themimgelement and the replace won't find it, as per the comment noted on my answer below. OP may know the HTML right now, but it's always best to code defensively so that by simply changing the input you won't break the logic.