這裏是有一段代碼:jQuery的:«孩子»VS«.find»+«.live»
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,WORKS:
attachEvents(
$(".thematicHeaderBox").find(".activatedUsual"),
self.elem.box.thematic.settings.event
);
attachEvents FUNC:
function attachEvents (elems, data) {
for(var p in data){
if(data.hasOwnProperty(p)){
elems.live(
data[p].name,
data[p].callback
);
}
}
}
數據是一個對象事件名稱和回調使用的數組。
問題是爲什麼只有第二個變體正常工作。
對不起,但是問題是什麼? – 2012-02-26 08:51:29
問題是爲什麼只有第二個變體能正常工作。 – 2012-02-26 17:07:30