Skip to content

Instantly share code, notes, and snippets.

@Restoration
Created June 11, 2016 05:52
Show Gist options
  • Select an option

  • Save Restoration/ffda9bac9788dc89c4b1e15d5fc604d0 to your computer and use it in GitHub Desktop.

Select an option

Save Restoration/ffda9bac9788dc89c4b1e15d5fc604d0 to your computer and use it in GitHub Desktop.
setTimeoutで引数を渡す
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
</head>
<body>
<script>
jQuery(function($){
$('.trigger').onclick(function(){
function alertFnc($(this)){
alert($(this));
}
setTimeout(alertFnc(),300);
var target = $(this);
setTimeout(function(){
//ここに処理を記述
//$(this)をsetTimeout関数に渡す時は第三引数に渡す
},300,target);
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment