0
셀에 대한 참조를 가져 오는 중이고 null로 표시됩니다. 올바르게 이해한다면 변수를 참조 할 수 있어야합니다. 옳은?자바 클로저 범위 지정 문제
$('td[someAttr]').mouseenter(function(cell) {
var timeoutId = setTimeout(function() {
// what should variable cell be?
}, 1000);
});
또는
는$('td[someAttr]').mouseenter(function(cell) {
var timeoutId = setTimeout(function() {
// what should variable cell be?
}, 1000, cell);
});
UPDATE :이 분명했지만, 난이 질문하는 이유는이 당신이 가지고있는 경우 cell.pageX이 정의 될 수 있기 때문이었다
$('td[someAttr]').mouseenter(function() {
var cell = this; //
var timeoutId = setTimeout(function() {
alert(cell.pageX); // cell.pageX will return null
}, 1000);
});
그러나, 너는 :
$('td[someAttr]').mouseenter(function(cell) {
alert(cell.pageX); // works fine as cell.pageX will have correct value.
});
이것은 분명했습니다. 그러나 제가 요청한 이유는 cell.pageX가 정의되지 않았기 때문이며, 업데이트를 게시하고 내 뜻을 보여줄 것입니다. –