Jquery Accordion - 手动激活
我正在使用 Jquery Accordion 插件。
我想在页面加载时打开某个面板。
我正在尝试这样做,通过 ID 来识别它:
selected = $("#1")
$('ul.accordiontasks').accordion( {
autoHeight: false,
active: selected
});
这似乎没有激活 ID 1 的手风琴面板,任何人都可以看到我做错了什么,并可能为我指出正确的方向吗?
干杯
埃夫
I am using the Jquery Accordion plugin.
I would like to when the page is loaded open a certain panel.
I am trying to this like so, by identifying it by ID:
selected = $("#1")
$('ul.accordiontasks').accordion( {
autoHeight: false,
active: selected
});
This does not seem to activate the accordion panel with the ID 1, can anyone see what I am doing wrong and maybe point me in the right direction?
Cheers
Eef
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
HTML 元素 ID 不能以数字开头 (ref) ,它们必须以字母开头。如果您的代码片段准确,那么您的 HTML 就不准确。另请注意,您不需要提供元素,可以直接提供选择器。
HTML element ids can't start with numbers (ref), they have to start with letters. If your code snippet is accurate then your HTML isn't. Note also that you don't need to supply an element, you can supply the selector directly.
您始终可以触发它:
You can always trigger it: