ドロップダウンメニューに対して独自の遅延機能を実行しました。私はJavaScriptに少し慣れていないので、これをより良い方法で実行できるかどうか知りたいですか?
var $hasSubpages = $("#divContainer .classForPagesWithSubpages");
function theFunction(){$('#theID').find('.classForChild').slideDown(400);}
var timer;
$hasSubpages.hover(
function (){
timer = setTimeout(theFunction, 500);
$(this).attr('id','theID');
},
function(){
clearTimeout(timer);
$(this).attr('id','').find('.classForChild').slideUp(400);
}
);