不会在jQuery中点击ul li

时间:2015-12-13 16:16:24

标签: jquery click html-lists

问题是单击<ul id=ulSemtMahalle class=ulList> <li><div class=divIlceHeader>Çukurova</div> <ul class=ulListSemt> <li id='liSemt61' > <div class='divSemt' name='chkIlceler' > <input type='checkbox' id='chkSemt61' class='big-checkbox'>Mahfesığmaz </div> <ul id=ulListMahalle> <li id='liMahalle161' > <div class='divMahalle' name='chkIlceler' > <input type='checkbox' id='chkMahalle161' class='big-checkbox'>Belediyeevleri Mah. </div> </li> <li id='liMahalle162' > <div class='divMahalle' name='chkIlceler' > <input type='checkbox' id='chkMahalle162' class='big-checkbox'>Beyazevler Mah. </div> </li> <li id='liMahalle163' > <div class='divMahalle' name='chkIlceler' > <input type='checkbox' id='chkMahalle163' class='big-checkbox'>Esentepe Mah. </div> </li> </ul> </li> </ul> </li> </ul> 时jQuery不会触发。 我需要你的帮助来了解问题所在。

HTML:

$('ul#ulListMahalle').on('click', 'li', function () {
    console.log("li clicked");
});

jQuery的:

arr=[Data(:).Date];
arr=arr.^2;
for a=1:numel(arr)
   Data(a).Date=arr(a);
end

2 个答案:

答案 0 :(得分:0)

您的选择器不正确:

(lldb) po [0x7fce2b95d480 class]
XXXViewController
(lldb) e (BOOL)[0x7fce2b95d480 respondsToSelector:@selector(viewDidAppear:)]
(BOOL) $2 = YES
(lldb) e (void)[0x7fce2b95d480 viewDidAppear:YES]
error: Execution was interrupted, reason: breakpoint 1.1.
The process has been returned to the state before expression evaluation.
2015-12-13 18:19:09.316 [13959:7671911] -[XXXViewController viewDidAppear:]: unrecognized selector sent to instance 0x7fce2b95d480

小提琴http://jsfiddle.net/6mvjrbtz/

答案 1 :(得分:0)

这对我有用。您将在浏览器的控制台窗口中看到li单击的注释。另外,确保在代码上方添加了jquery插件,并在document.ready()函数中添加了代码