0
私はこのコードが何をするか理解していなかった。以下のコードは何を意味していますか?
.bind(this);
は(私はzurb基礎ドロップダウンプラグインからこのコードを取った)
.on('mouseleave.fndtn.dropdown', '[data-dropdown], [data-dropdown-content]', function (e) {
var $this = $(this);
self.timeout = setTimeout(function() {
if ($this.data('dropdown')) {
var settings = $this.data('dropdown-init');
if (settings.is_hover) self.close.call(self, $('#' + $this.data('dropdown')));
} else {
var target = $('[data-dropdown="' + $(this).attr('id') + '"]'),
settings = target.data('dropdown-init');
if (settings.is_hover) self.close.call(self, $this);
}
}.bind(this), 150);
})
jQueryを3と、それは互換性はありますか? jQueryのからのthis
に匿名関数の内部でthis
を設定します はhttp://jquery.com/upgrade-guide/3.0/#deprecated-bind-and-delegate
.bind - [documentation](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_objects/Function/bind) –
これは 'this'コンテキストを関数にバインドするので、その関数の中のthis'は、関数がどのように呼び出されているかにかかわらず、常に 'bind()'に渡される 'this'を参照します。 – Tushar
'jquery 3と互換性があります ' - jQueryは単なるjavascriptライブラリなので、javascriptの動作方法は変わりません。 –