Skip to content

Instantly share code, notes, and snippets.

@Restoration
Created January 30, 2017 07:53
Show Gist options
  • Save Restoration/db7e43d4fe90b329dd64084686e99215 to your computer and use it in GitHub Desktop.
Save Restoration/db7e43d4fe90b329dd64084686e99215 to your computer and use it in GitHub Desktop.
setTimeoutで$(this)を渡す方法
jQuery(function($){
$('.trigger').onclick(function(){
function alertFnc($(this)){
alert($(this));
}
setTimeout(alertFnc(),300);
var target = $(this);
setTimeout(function(){
//ここに処理を記述
//$(this)をsetTimeout関数に渡す時は第三引数に渡す
},300,target);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment