下面的代碼中的「this」和「element」是指什麼情況而不是選擇器?
$("a.tag")
.each(
function (index, element) {
console.log("'this' is " + this);
console.log("'element' is " + element);
}
)
產生以下多次有元素:
'this' is file:///C:/Projects/PlaceTag/PlaceTag/default.html# default.html:50
'element' is file:///C:/Projects/PlaceTag/PlaceTag/default.html#
有趣了,從來沒有看到過:http://jsfiddle.net/nYHfb/ –
@JasonP同樣的現象被提及[這裏](http://stackoverflow.com/questions/3363848/javascript -this-keyword-returning-href-attribute-rather-than-object-on-anchor) – matewka
Try console.log(this === el); – CodeGroover