DEV Community

Rose
Rose

Posted on

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 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.

Top comments (2)

Collapse
 
techniqueen profile image
Rose

LOL oh no!!! It appears that the "click" part of the text that I posted, umm, messed up my post. Maybe I shouldn't have posted the "exact" text???