简体   繁体   中英

If I type "hello" into a text box, how can I make an alert appear by pressing a button?

I would like to create code to make it so when I type "hello" into a text box I can press the button below and a certain alert pop-up will appear. I also want to add more of these to different words as well. What should I add to my code to make this work?

<!DOCTYPE html>
<html>
<head>
<title>thisThat</title>
<style>
    body {
        background-color: #333333;
    }
    .input, .output {
       border: 0;
    padding: 8px;
    font-size: 14px;
    }
    .output {
        background-color: #ff0000;
    }
    p {
        font-size: 18px;
    }
</style>
</head>
<body>
<center><h3>thisThat</h3></center>
<center><p>
If
</p></center>
<center><input placeholder="this..." class="input"></center>
<center><p>then</p></center>
<center><button class="output">that...</button></center>
</body>
</html>

Yes, you do that with JavaScript. There are some great online resources for learning HTML, CSS and JavaScript: https://www.codeschool.com/ http://pluralsight.com/ http://teamtreehouse.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM