jQuery is not working in Firefox. It works fine in IE and Google chrome, but when I am trying to run my application in Mozilla Firefox jQuery is not working. Any guesses? Here is my piece of code
jQuery不在Firefox中工作。它在IE和谷歌chrome中运行良好,但是当我试图在Mozilla Firefox中运行我的应用程序时,它就不起作用了。猜测吗?这是我的代码。
<!DOCTYPE HTML PUBLIC>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script>
<style>
div{
width:200px;
height:100px;
border:1px solid red;
}
</style>
</head>
<body>
<div> One</div>
<div>Two</div>
<div>Three</div>
</body>
<script>
$('div').click(function(){
alert("Hello.....");
});
</script>
</html>
3 个解决方案
#1
9
you should use the dom ready event
您应该使用dom ready事件
$(document).ready(function(){
$('div').click(function(){
alert("Hello.....");
});
});
#2
3
Put your jquery Code inside document.ready
.
将jquery代码放在document.ready中。
$(document).ready(function() {
$('div').click(function(){
alert("Hello.....");
});
});
Give your div a proper class.just like
给你的div一个合适的类。就像
<div class="clsDiv"> One</div>
amd call like this.
amd称这样的。
$('.clsDiv').click(function(){
#3
0
lukenz and Shree nailed it. JQUery event handlers for html elements must first be registered in $(document).ready().
lukenz和Shree搞定了。html元素的JQUery事件处理程序必须首先在$(document).ready()中注册。
#1
9
you should use the dom ready event
您应该使用dom ready事件
$(document).ready(function(){
$('div').click(function(){
alert("Hello.....");
});
});
#2
3
Put your jquery Code inside document.ready
.
将jquery代码放在document.ready中。
$(document).ready(function() {
$('div').click(function(){
alert("Hello.....");
});
});
Give your div a proper class.just like
给你的div一个合适的类。就像
<div class="clsDiv"> One</div>
amd call like this.
amd称这样的。
$('.clsDiv').click(function(){
#3
0
lukenz and Shree nailed it. JQUery event handlers for html elements must first be registered in $(document).ready().
lukenz和Shree搞定了。html元素的JQUery事件处理程序必须首先在$(document).ready()中注册。