【问题标题】:If I type "hello" into a text box, how can I make an alert appear by pressing a button?如果我在文本框中输入“你好”,如何通过按下按钮来显示警报?
【发布时间】:2014-05-18 19:22:39
【问题描述】:

我想创建代码来实现它,所以当我在文本框中输入“hello”时,我可以按下下面的按钮,然后会出现一个特定的警报弹出窗口。我还想在不同的单词中添加更多这些。我应该在我的代码中添加什么来完成这项工作?

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

【问题讨论】:

  • 旁注,不要使用 &lt;center&gt; 标签,它在 1950 年左右被弃用。
  • 你试过什么?在询问它是如何完成的之前,您至少需要尝试解决您的问题。如果不真正学习如何去做,您将无法建立掌握编码技巧所必需的基础知识。
  • 我确实尝试了几次,但我删除了那些。这是来自 stackoverflow 的解决方案,但没有奏效。

标签: javascript css html button input


【解决方案1】:

是的,您可以使用 JavaScript 做到这一点。有一些很棒的在线资源可用于学习 HTML、CSS 和 JavaScript:https://www.codeschool.com/http://pluralsight.com/http://teamtreehouse.com/

【讨论】:

    猜你喜欢
    • 2020-04-12
    • 1970-01-01
    • 1970-01-01
    • 2016-03-24
    • 1970-01-01
    • 2013-11-03
    • 1970-01-01
    • 2015-05-17
    • 2019-08-07
    相关资源
    最近更新 更多