Hello everyone!!! :) …and, what am I doing wrong?

EDIT: It seems that I was missing one tiny little period. I fixed that, and it works now! Who knew one little character could make a whole function inoperable?!

Hi everyone! I’m SO EXCITED to be joining your community! 🙂 Can someone please help me fi…


This content originally appeared on DEV Community and was authored by Rose

EDIT: It seems that I was missing one tiny little period. I fixed that, and it works now! Who knew one little character could make a whole function inoperable?!

Hi everyone! I'm SO EXCITED to be joining your community! :) Can someone please help me figure this out?

I've been studying javaScript for about a week, and dabbling in some HTML, and this morning I decided to try and follow along with a YouTube video, but it's just not working for me. Let me post the link, then I'll copy the EXACT text I have in Notepad (yeah.. I just started... so I'm using notepad, lol)

I'm able to see index.html in my web browser. The "hello", the text box, and the button all show up just fine. But when I type "red" or "green" like the YouTube video shows... the text just stays black. Does this not work in notepad, or do I have some kind of error in my text? Or is the video just wrong?

https://www.youtube.com/watch?v=rjLHje_SkE4

here's what I have in my notepad:


Hello!



Click
    <script>
    function pressed() {
        var text = document.getElementById("inp").value;
    if (text === "red"){
    document.getElementById("header").style.color = "red";
    }else if(text==="green"){
    document.getElementById("header").style.color = "green";
    }else{
    document.getElementById("header")style.color = "black";
    }
    }

</script>
</body>

Thank you SO much for your help, because I just want this to work, and I need the practice, but I've hit a wall and I can't figure out what I'm doing wrong.


This content originally appeared on DEV Community and was authored by Rose


Print Share Comment Cite Upload Translate Updates
APA

Rose | Sciencx (2025-01-15T21:48:06+00:00) Hello everyone!!! :) …and, what am I doing wrong?. Retrieved from https://www.scien.cx/2025/01/15/hello-everyone-and-what-am-i-doing-wrong/

MLA
" » Hello everyone!!! :) …and, what am I doing wrong?." Rose | Sciencx - Wednesday January 15, 2025, https://www.scien.cx/2025/01/15/hello-everyone-and-what-am-i-doing-wrong/
HARVARD
Rose | Sciencx Wednesday January 15, 2025 » Hello everyone!!! :) …and, what am I doing wrong?., viewed ,<https://www.scien.cx/2025/01/15/hello-everyone-and-what-am-i-doing-wrong/>
VANCOUVER
Rose | Sciencx - » Hello everyone!!! :) …and, what am I doing wrong?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/01/15/hello-everyone-and-what-am-i-doing-wrong/
CHICAGO
" » Hello everyone!!! :) …and, what am I doing wrong?." Rose | Sciencx - Accessed . https://www.scien.cx/2025/01/15/hello-everyone-and-what-am-i-doing-wrong/
IEEE
" » Hello everyone!!! :) …and, what am I doing wrong?." Rose | Sciencx [Online]. Available: https://www.scien.cx/2025/01/15/hello-everyone-and-what-am-i-doing-wrong/. [Accessed: ]
rf:citation
» Hello everyone!!! :) …and, what am I doing wrong? | Rose | Sciencx | https://www.scien.cx/2025/01/15/hello-everyone-and-what-am-i-doing-wrong/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.