私はから「これ」を渡そうとしています:
myVar = setInterval("displayDate(this )",1000);
そして、ステップスルーするときに「div.test」を渡す必要がありますが、それを受け取るときは次のようになります。
function displayDate(obj){
}
「窓」って言うの???以下は、私が構築している JavaScript です。イベントをトリガーするクラスの基盤を構築しようとしています。最終的には、Sprite の解析を通じて、elements.src=".jpg" を可変レート (現在は 100 に設定) で変更する予定です。しかし、私は現在これに固執しており、.html コードに onmousemove 属性などを挿入してきれいに保つ必要はありません。. . これは .html/.css/.js を書いて 3 日目に過ぎないことを覚えておいてください。
// This helps create a static variable that isn't polluting the global namespace
var incr = (function () {
var i = 0;
return function(){ return i++; };
})();
// This perform all of the functions that we would like with some error handling
function displayDate(obj){
var counter = incr();
try{
obj.innerHTML=counter;
}catch(err){
var txt="There was an error on this page.\n\n";
txt+="Error description: " + err.message + "\n\n";
txt+="Click OK to continue.\n\n";
alert(txt);
}
}
// This is our trigger that sets an interval for our main Java function
$(function(){
var myVar;
$(".test").hover( function() {
// The mouse has entered the element, can reference the element via 'this'
myVar = setInterval("displayDate(this )",100);
},function () {
// The mouse has left the element, can reference the element via 'this'
clearInterval(myVar);
}
);
});