【发布时间】:2012-03-16 03:23:20
【问题描述】:
这里有一些代码:
HTML:
<div class="thematicHeaderBox group">
<h3 class="thematicHeader group">SMTH</h3>
<button class="activatedUsual" style="float: right; ">on</button>
</div>
JS,不工作:
attachEvents(
$(".thematicHeaderBox").children(".activatedUsual"),
self.elem.box.thematic.settings.event
);
JS,工作:
attachEvents(
$(".thematicHeaderBox").find(".activatedUsual"),
self.elem.box.thematic.settings.event
);
附加事件函数:
function attachEvents (elems, data) {
for(var p in data){
if(data.hasOwnProperty(p)){
elems.live(
data[p].name,
data[p].callback
);
}
}
}
data 是一组对象事件名称和要使用的回调。
问题是为什么只有第二种变体可以正常工作。
【问题讨论】:
-
对不起,请问有什么问题?
-
问题是为什么只有第二个变体可以正常工作。