我正在使用fancybox,希望在fancybox执行之前获取元素的类。我的代码如下:
$(".agent-file-popup").fancybox({
'onStart': function () {
console.log($(this).attr('class'));
console.log($(".agent-file-popup").attr('class'));
return true;
}
});
第一个日志输出 "undefined" 但第二个日志输出了正确的类。为什么在这种情况下我不能使用 "this" 作为元素?
$.ajax
一样,只要它是按设计和文档正确的。 - gdoron