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
<!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>
you should use the dom ready event
$(document).ready(function(){
$('div').click(function(){
alert("Hello.....");
});
});
Put your jquery Code inside document.ready
.
$(document).ready(function() {
$('div').click(function(){
alert("Hello.....");
});
});
Give your div a proper class.just like
<div class="clsDiv"> One</div>
amd call like this.
$('.clsDiv').click(function(){
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With