i have a problem regarding to growl notification in jquery. I have this error in IE (which I know not the best choice to test your code but just to your error in javascript) "Object doesn't support this property or method".
notifyBidding.js
$(document).ready(function(){
addNotice();
setTimeout(function(){
addNotice();
},4000);
$('#growl')
.find('.close')
.live('click', function(){
$(this)
.closest('.notice')
.animate({
border: 'none',
height: 0,
marginBottom: 0,
marginTop: '-6px',
opacity: 0,
paddingBottom:0,
paddingTop:0,
queue:false
},1000, function(){
$(this).remove();
});
});
});
function addNotice(){
$('#growl')
.append($('<div id="bidTo"></div>').html($('<img id="bg2" src="notification.png" width="250" height="75"></img><p id="tag2">This item is about to end</p><img id="dp2" src="temporary.jpg"/><p id="bidTime" style="font-family:arial narrow; font-size:12; color:rgb(171,14,21); text-transform:uppercase; position:absolute; top:25px; left:85px"><b>about to end</b></p>')))
.hide()
.appendTo("#growl")
.fadeIn(1000)
.fadeOut(3000)
$('#bidTo').contents().unwrap();
}
welcome.php
<html>
<head>
<link rel="stylesheet" type="text/css" href="design2.css"/>
<script type="text/javascript" src='script.js'></script>
</head>
<script type="text/javascript" src="jquery-1.11.0.min.js"></script>
<script src="jquery-1.11.0.min.js"></script>
<script src="jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>
<script src="notification.js"></script>
<script src="notifyBidding.js"></script>
<body>
<a id='imgCart' href='#'></a>
<div id='notification' >
<img id='bg' src='notification.png' width='1110' height='65'></img>
<p id='tag'>There are still in your shopping cart</p>
<p id='noToPay'>5</p>
</div>
<div id='growl'></div>
</body>
</html>
1 Answer 1
You need to put your <script> in the <head> section or before closing </body> tag of your page.
<head>
<link rel="stylesheet" type="text/css" href="design2.css"/>
<script type="text/javascript" src='script.js'></script>
<script type="text/javascript" src="jquery-1.11.0.min.js"></script>
<script src="jquery-1.11.0.min.js"></script>
<script src="jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>
<script src="notification.js"></script>
<script src="notifyBidding.js"></script>
</head>
Also, since you're using jQuery version 1.11 and .live() has been removed in version 1.9, you need to use .on() instead , so you can change:
$('#growl').find('.close').live('click', function(){ .....
to:
$('#growl').find('.close').on('click', function(){ .....
Besides that, if your scripts.js utilize jQuery or other plugins, you must include it after you've included jQuery and other plugins.
Last note is that you just need to include jQuery once instead of twice like what you're doing at this moment.
.oninstead of.live,.liveis deprecated