密码显示内容(passcode to show content)

编程入门 行业动态 更新时间:2024-10-28 20:17:50
密码显示内容(passcode to show content)

我正在尝试创建一个简单的设置,以便当某个代码输入到表单框中时,会显示一个隐藏的元素。 如果你能帮助我,那就太好了。 谢谢!

<form> Enter the passcode to see the content: <input id="pwd" type="text" name="pwd" /> </form> <div id="content" style="display:none;"> testing 123 </div> <script> $function(){ $(form).keyup(function() { $('input').trigger('change'); }); if ($('pwd').val() == supportingcauses){ $('content').show('slow'); } }; </script>

http://jsfiddle.net/jaruesink/RTG4f/

I'm trying to create a simple set-up so that when a certain code is entered into a form box, then a hidden element shows. If you could help me out, that'd be great. Thanks!

<form> Enter the passcode to see the content: <input id="pwd" type="text" name="pwd" /> </form> <div id="content" style="display:none;"> testing 123 </div> <script> $function(){ $(form).keyup(function() { $('input').trigger('change'); }); if ($('pwd').val() == supportingcauses){ $('content').show('slow'); } }; </script>

http://jsfiddle.net/jaruesink/RTG4f/

最满意答案

您的代码中唯一的问题似乎是您的代码缺少一些字符。 以下是它的外观:

... if ($('#pwd').val() == "supportingcauses"){ $('#content').show('slow'); } ...

我添加了#来表示它的id和括号表示supportingcauses引用是一个字符串。

编辑

完整正确的代码是:

<form> Enter the passcode to see the content: <input id="pwd" type="text" name="pwd" /> </form> <div id="content" style="display:none;"> testing 123 </div> <script> $("#pwd").keyup(function() { if ($('#pwd').val() == "supportingcauses"){ $('#content').show('slow'); } }); </script>

或者如下所示: http : //jsfiddle.net/nayish/MrjxY/3/

It seems your only problem in your code is that your codes missing a bit of chars. Here's how it should look:

... if ($('#pwd').val() == "supportingcauses"){ $('#content').show('slow'); } ...

I added the # to signify its an id and the parenthesis to signify supportingcauses is a string.

EDIT

The full correct code would be:

<form> Enter the passcode to see the content: <input id="pwd" type="text" name="pwd" /> </form> <div id="content" style="display:none;"> testing 123 </div> <script> $("#pwd").keyup(function() { if ($('#pwd').val() == "supportingcauses"){ $('#content').show('slow'); } }); </script>

Or as shown here: http://jsfiddle.net/nayish/MrjxY/3/

更多推荐

本文发布于:2023-07-27 17:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1293648.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:密码   内容   passcode   show   content

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!