Can someone tell me why my JQuery plugin doesn't work? I followed the steps carefully [closed]
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
开发者_如何学Python Improve this questionI followed the steps here: http://tympanus.net/codrops/2009/10/29/jbar-a-jquery-notification-plugin/
I just want it to display a notification bar when on body load, but it's not working.
There is one thing I changed that's different than the tutorial. I did $(this).ready
on line 9 of the JQuery plugin.
Thanks!
Edit: It binds to body ready perfectly. (notice the alert). It just doesn't show the bar.
insertBefore($('.content'))
It seems to me that you are inserting your bar before something with the "content" class, but you don't have any element with that class.
There is no $(this).ready()
in jQuery, unless this
points to document
.
Generally, you don't onDOMready things in your plugin - that is up to the person implementing your plugin to do.
Remove the last comma in options. The last option won't have a comma at the end.
Also, Wrap it in:
$(document).ready(function(){
});
Read the comments on the page where you got the plugin. It explains that the plugin, as written, only works on a button press (the element that you call .bar on needs to be a button).
Another comment also shows how you should be able to make it work the way you want:
RAVI TOM SEPTEMBER 6TH, 2010 AT 10:10
in html file change this line
$(“#msgup”).bar({
to
$(“body”).bar({
In jquery.bar.js file change the line number 9 to
$this.ready(function(e){
These changes will help you to show notification once page loads
精彩评论