So I am new to JS and am trying to figure out the basics. I decided to make a basic web page text editor. Right now I am trying to differentiate between words with JS. Here is the code I have, basically it determines whether or not the word "bob" has been entered in the textarea.
<script>
function findBob() {
var inputText = document.getElementById("box").innerHTML;
if(inputText === "bob") {
document.getElementById("box").innerHTML = "true";
}
if (inputText !== "bob") {
document.getElementById("box").innerHTML = "false";
}
}
</script>
<textarea rows=10; col= 5; id="box">
bob</textarea>
<button onClick="findBob();">FIND BOB</button>
Now, after I click the button saying "FIND BOB", it changes the text to "true" which is perfect, however, if I add some gibberish to the textarea, then click FIND BOB again, nothing happens. If I do anything to the textarea the function will not work. Even if I reload the page, backspace "bob" and retype "bob" nothing happens.
Now I expect that I have broken some JavaScript syntax, or some such thing, but I cannot figure it out. What am I doing wrong?
-EDIT- I am using ===
, as opposed to other methods because of this other StackOverflow post, find it here.