Can someone help me to make html and javascript about adding a word in the middle of a sentence with user input? Thanks...
Sentence: Aku sedang [User Input] disekolah.
Input Box | Button to make sentence
the result of the sentence that has been added to the word and entered by the user ex:
Aku sedang makan disekolah.
CodePudding user response:
for the html body:
<p>Aku sedang <span id="sentence">_____</span> di sekolah.</p>
<input type="text" id="userInput"> <button onclick="readMore()">modify</button>
then add the script
<script>
function readMore(){
let word = document.getElementById("userInput").value;
document.getElementById("sentence").innerHTML = word;
}
</script>
you can read other usability of HTML DOM in here