私はサイクリング・イメージ・スライダを開発しようとしており、開発のために参照しているドキュメントについて質問があります。セレクタのないJQuery?
JQuery関数は実際にセレクタを呼び出すのではなく、私はそれをどのように読むべきか正確には分かりません。
$.fn.cycle = function(options, arg2) {
var o = { s: this.selector, c: this.context };
上記のスクリプトは、私のjavascriptドキュメントにあり、下のメソッドは、上記のスクリプトを呼び出すHTMLドキュメントにあります。
$(document).ready(function() {
$('.headline').cycle({
fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle,
cleartypeNoBg:true
});
。見出しは、HTMLドキュメントで定義されているクラスです。これはセレクタがあり、$ .fn.cycleはありませんので、私は混乱しています。
.headで見出しが.fnに値を渡していますか?もしそうなら、それはどのように変数のそのセクションにだけ渡されますか?
あなたはフルjQueryのは、それを機能見たい場合はここにある:
$.fn.cycle = function(options, arg2) {
var o = { s: this.selector, c: this.context };
// in 1.3+ we can fix mistakes with the ready state
if (this.length === 0 && options != 'stop') {
if (!$.isReady && o.s) {
log('DOM not ready, queuing slideshow');
$(function() {
$(o.s,o.c).cycle(options,arg2);
});
return this;
}
// is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
return this;
}
// iterate the matched nodeset
return this.each(function() {
var opts = handleArguments(this, options, arg2);
if (opts === false)
return;
opts.updateActivePagerLink = opts.updateActivePagerLink || $.fn.cycle.updateActivePagerLink;
// stop existing slideshow for this container (if there is one)
if (this.cycleTimeout)
clearTimeout(this.cycleTimeout);
this.cycleTimeout = this.cyclePause = 0;
var $cont = $(this);
var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children();
var els = $slides.get();
if (els.length < 2) {
log('terminating; too few slides: ' + els.length);
return;
}
var opts2 = buildOptions($cont, $slides, els, opts, o);
if (opts2 === false)
return;
var startTime = opts2.continuous ? 10 : getTimeout(els[opts2.currSlide], els[opts2.nextSlide], opts2, !opts2.rev);
// if it's an auto slideshow, kick it off
if (startTime) {
startTime += (opts2.delay || 0);
if (startTime < 10)
startTime = 10;
debug('first timeout: ' + startTime);
this.cycleTimeout = setTimeout(function(){go(els,opts2,0,(!opts2.rev && !opts.backwards))}, startTime);
}
});
'$ .fn.cycle'は、それがこれを開始するには絶好の場所ではありません機能 – mgraph
プラグインjQueryの - http://docs.jquery.com/Plugins/Authoring – jrummell
@mgraph: 'typeof $ .fn.cycle'は同意しません。もちろん関数ですが、プラグインにするjQueryを拡張するために使用されます。 –