I am trying to get a function to work for each .download开发者_StackOverflow社区_now
element.
I have used the two below with no luck, any idea why?
$(".download_now").each.tooltip({ effect: 'slide'});
$(".download_now").each(tooltip({ effect: 'slide'}));
Neither answer will work, I'm trying it on the following: http://flowplayer.org/tools/demos/tooltip/any-html.html
each() takes a function as an argument. Within that function you can use this
to refer to the current element:
$(".download_now").each(function(){
$(this).tooltip({ effect: 'slide'});
});
You need to wrap the tooltip call inside a function.
each()
will then call the function for each iteration, passing the current element as this
.
Like so:
$(".download_now").each(function(){
$(this).tooltip({ effect: 'slide'})
});
You need to pass a function into the each method. Typically, an anonymous function is used like so:
$('.download_now').each(function() {
...
});
Each DOM object can be referenced using this
within the function.
You don't need .each()
. Just do:
$(".download_now").tooltip({ effect: 'slide'});
(like the first page of the showcase shows)
精彩评论