jQuery plugins - accessing element from the options [closed]
开发者_如何学C
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this questionMost jQuery plugins have options like this one for example (cycle):
$("ul").cycle({
fx: 'fade',
startingSlide: 1,
speed: 500,
pause: true});
The plugin will do his thing on all elements with the class/ID you specify, in this case all <UL>
elements.
How can I access this <UL>
's child elements from within one of these options.
For example startingSlide
only accepts numbers, and I want to pass a function that returns a number, instead of just a number.
The problem is that within that function I don't know how to access the current <UL>
the plugin is working with (not all ULs)
The plugin works only on the wrapped set that you specify eg $("ul")
, if you want to something to happen to children of ul
, you will have to specify that instead $("ul > li")
. So the plugin will do its job on the wrapped set/selector you specify to it.
精彩评论