just wondering if anyone could have a look at my code that ive been trying to port to a plugin. There seem to be no errors getting logged, I just cant work out not working (this is my first attempt at a jQuery plugin so I really don't quite know what I'm doing, even though I've done a lo开发者_StackOverflow社区t of work with the jQuery library).
Here is the original code (with comments):
http://jsfiddle.net/GZLQH/1/And this is my attempt and a plugin:
http://jsfiddle.net/PnEYN/Cheers
CharlieHere you go: http://jsfiddle.net/aGFdJ/4/
The main point:
- Since the
this
pointer does not always point to the original element, you need to store a reference to it somewhere.
Side notes:
- As experimentX noted in the comments, you need to reference jQuery.
background:url(spark_01.png)
is not going to work in jsFiddle.- Consider using a
for(var i = 0; i < sparks.length; i++)
when looping over a array, instead of thefor(var key in sparks)
.
精彩评论