Jquery 显示内容的密码
我试图创建一个简单的设置,这样当某个代码输入到表单框中时,就会显示一个隐藏的元素。如果你能帮我,那太好了。谢谢Jquery 显示内容的密码,jquery,html,Jquery,Html,我试图创建一个简单的设置,这样当某个代码输入到表单框中时,就会显示一个隐藏的元素。如果你能帮我,那太好了。谢谢 <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&
<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>
这不是一种安全的密码安全方法,但下面是如何做到这一点
代码中唯一的问题似乎是代码缺少了一些字符。下面是它的外观:
...
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>
或者如图所示:这不是最好的主意,因为任何以html格式查看您的html页面的人都可以看到您隐藏的内容。。。所以没有真正的理由用密码来保护它…看起来nayish建议使用AJAX进行服务器访问。它不一定要安全。这只是我在网站上需要的一个小把戏。谢谢