如何在下面的swatchbook函數中運行「._ openclose()」例如?如何從插件外部的插件中運行jquery函數?
http://tympanus.net/Tutorials/SwatchBook/index3.html
我嘗試這樣的東西:
$('#sb-container').swatchbook = function() {
this._openclose()
}
如何在下面的swatchbook函數中運行「._ openclose()」例如?如何從插件外部的插件中運行jquery函數?
http://tympanus.net/Tutorials/SwatchBook/index3.html
我嘗試這樣的東西:
$('#sb-container').swatchbook = function() {
this._openclose()
}
有很多的這個插件上this page的文檔中的有用信息。 jQuery的東西是底部。
沒有使用插件,我不確定它是如何工作的,但我可以馬上發現你的'this'不是一個jQuery對象。嘗試:
$('#sb-container').swatchbook = function() {
$(this)._openclose()
});
OR
$('#sb-container').swatchbook = function() {
_self._openclose()
});
_self被聲明爲變量 '這個' 的插件:
var _self = this;
由closeIdx : 11
行指定可以觸發事件上的項目。
$(function() {
$('#sb-container').swatchbook({
// number of degrees that is between each item
angleInc : 15,
neighbor : 15,
// if it should be closed by default
initclosed : true,
// index of the element that when clicked, triggers the open/close function
// by default there is no such element
closeIdx : 11
});
});
function test(){
$('.sb-toggle').trigger('click');
}
HTML:
<div id="test" onclick="test();">Test</div>
我試圖讓它沒有內部切換鏈接工作,只是一個外部鏈接切換 – Dieter
似乎並沒有工作。檢查文檔... – Dieter