[英]<div> not hiding on click?
This div
should hide on click. 该div
应该在点击时隐藏。 I tested the code in notepad++ and it worked. 我在notepad ++中测试了代码,并且可以正常工作。 But in a maven project, I added the code to a JSF
page and it does not hide on click. 但是在一个maven项目中,我将代码添加到了JSF
页面中,并且单击时不会隐藏。 Why does it not work in a JSF Page? 为什么在JSF页面中不起作用? or is something else wrong? 还是其他问题?
Here is the code: 这是代码:
<div id="cookiew">
<b>This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies. <b>
<button type="button" id="cookieb" class="btn btn-default" >OK</button>
<style>
#cookiew{
width: 960px;
display: block;
margin-left: auto;
background-color: red;
width: 100%;
text-align: center;
color: white;
height: 45px;
padding-bottom: 5px;
padding-top: 5px;
}
#cookieb{
margin-left: 3px;
margin-right: 3px;
}
</style>
<script>
$(document).ready(function(){
$("#cookieb").click(function(){
$(cookiew).hide();
});
});
</script>
</div>
Also, here are my scripts: 另外,这是我的脚本:
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<h:outputScript library="js" name="myjs.js" />
Here is a JSFiddle: http://jsfiddle.net/7dyh5eun/ 这是一个JSFiddle: http : //jsfiddle.net/7dyh5eun/
In addition too what denise said. 另外丹尼斯说了什么。 It seems like jquery was not loaded. 似乎没有加载jquery。 Updated jsfiddle see here http://jsfiddle.net/7dyh5eun/4/ 更新的jsfiddle请参阅此处http://jsfiddle.net/7dyh5eun/4/
$(document).ready(function(){
$('#cookiePrompt').click(function(){
$('#cookiePrompt').hide();
});
});
Well, that is a strange place to put a script tag. 好吧,这是放脚本标签的奇怪地方。 But could the problem be: 但是问题可能是:
$(cookiew).hide();
should be 应该
$("#cookiew").hide();
? ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.