View Single Post
Old 10-28-2017, 06:51 AM  
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,058
Quote:
Originally Posted by starling View Post
Code:
<p>So this would be the paragraph and<span id="your_paragraph">THIS</span>is the word to be changed</p>
INPUT HERE: <input type="text" id="theText" />
<input type="button" id="btn" value="Update" />

<script>
var span = document.getElementById('your_paragraph');
var btn = document.getElementById('btn');
var txt = document.getElementById('theText');
btn.onclick = function(){
    span.textContent = txt.value;
};
</script>
The problem is it only works on one element instead of multiple. Is there a way to make it change all instances of the word to the same input, if I had multiple paragraphs?
You would need to go through all elements that can contain the word to be replaced and replace each one individually I would think.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote