I dont know why this is the case but my replace does not work. It is somehow unusual considering my syntax is correct.
info.textContent.replace('Title', "replaced");
where info is the variable that stores an element. It should actually replace all instances of Title with "replaced". I prefer not using innerText due to patibility issues and innerHTML due to security risks. textContent is supported by firefox and I have no idea what is going on.
I would appreciate some insight. I am learning javascript and tips for best practice are wele.
Below the full code in Jsfiddle:
/
I dont know why this is the case but my replace does not work. It is somehow unusual considering my syntax is correct.
info.textContent.replace('Title', "replaced");
where info is the variable that stores an element. It should actually replace all instances of Title with "replaced". I prefer not using innerText due to patibility issues and innerHTML due to security risks. textContent is supported by firefox and I have no idea what is going on.
I would appreciate some insight. I am learning javascript and tips for best practice are wele.
Below the full code in Jsfiddle:
http://jsfiddle/r7bL6vLy/123/
Share Improve this question asked Sep 14, 2015 at 19:00 AspergerAsperger 3,22211 gold badges59 silver badges106 bronze badges 01 Answer
Reset to default 8It works, it's just replace method returns new string you need to assign back:
info.textContent = info.textContent.replace('Title', "replaced");