var e = document.getElementById('anelement');
e.innerHTML = f.anelement
inside anelement I’d like to replace every occurance of a certain word e.g apple with orange how would I go about doing this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
innerHTMLis aStringobject which has thereplacemethod:Edit
As Matt Brock pointed out in comments, a simple
replacedoes not differentiate between whole words and substrings. A more precise solution, using regular expressions, would be: