【发布时间】:2014-12-12 15:54:57
【问题描述】:
我希望能够在可选的 jQueryUI 中获取用户单击的 <li> 元素。这是因为我想找出他们点击的元素是否已经被选中,然后根据它做一些事情。这是我工作的代码:
$(document).ready(function() // Execute all of this on load
{
// Add week selector
$(function() {
var startElementSelected = false;
$("#popupWeeks").selectable({
start: function(e) {
var classSelected = e.toElement.className.search("ui-selected");
if (classSelected != -1) {
startElementSelected = true;
} else {
startElementSelected = false;
}
}
});
});
});
问题是这适用于 chrome,但不适用于 Firefox,我可以用它来为两者都工作。我寻找了相当于e.toElement.className 的firefox,但找不到任何东西,而且我在点击事件的事件处理方面遇到了麻烦。
非常感谢任何帮助。
【问题讨论】:
-
如果您使用的是 jQuery,那么为什么不使用 jQuery?使用
.hasClass("ui-selected")而不是e.toElement.className.search("ui-selected");
标签: jquery selectable