我通常可以使用path
确定特定输入是否具有焦点,但这似乎不适用于选择性输入。
我可以使用$("#my_input").is(":focus")
为输入设置焦点,但仍然$("#my_input")[0].selectize.focus()
会返回$("#my_input").is(":focus")
。
当我在Chrome中检查元素时,我可以看到false
下方的div具有类属性my_input
,但我不清楚如何将其链接到focus
。
我还尝试了#my_input
和document.activeElement
等,但到目前为止还没有运气
答案 0 :(得分:1)
Selectize.js隐藏了您在标记中编写的输入,并显示了一些动态元素。
这些是您原始输入的旁边。
尝试:
if( $("#my_input").next(".selectize-control").find(".focus").length>0 ){
console.log("Selectize is focussed!");
}else{
console.log("Selectize is NOT focussed.");
}
如果你跟着我这个......通过查看" next" div如果有一个孩子有focus
课程,你就会知道它是否专注于......