【发布时间】:2015-01-15 09:27:39
【问题描述】:
我有一个文本框和按钮。我想在单击按钮时显示alert。但我有一个条件;输入文本值必须是X1。如果用户在文本框中写入X1,则显示警报GOOD,否则显示警报NOT GOOD。
如何使用 jQuery 做到这一点?这是我的html代码。
<input type="text" id="couponInput" class="couponInput" placeholder="Input Code" />
<button type="button" id="couponApply" class="couponApply">APPLY</button>
【问题讨论】:
-
这读起来像个简报。你有没有尝试过自己解决这个问题?
-
阅读文档:这里有一些你应该需要的方法
valclick。看看选择器:api.jquery.com/category/selectors -
@RoryMcCrossan 你是对的。我是 JQuery 的新手,当然我做了一些尝试,但它们不起作用。
-
这太基本了,我不敢相信您在 WEB 上找不到任何东西来解决您的预期行为。做一些搜索...
标签: javascript jquery html input