View Single Post
Old 10-28-2017, 05:31 AM  
starling
Confirmed User
 
Industry Role:
Join Date: Jan 2017
Posts: 312
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?
starling is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote