不好意思,有人可以帮我把这段代码翻译成普通的JS(如果有可能的话)??
$(function() {
$('#nav-accordion').dcAccordion({
eventType: 'click',
autoClose: true,
saveState: true,
disableLink: true,
speed: 'slow',
showCount: false,
autoExpand: true,
// cookie: 'dcjq-accordion-1',
classExpand: 'dcjq-current-parent'
});
});
答案 0 :(得分:2)
您需要将dcAccordion
插件中的所有代码翻译为本机JavaScript。不是一件容易的事。对于$(function () {})
,您可以执行以下操作:
window.ondomready = function () {
};
ondomready概念太大了,对于预告片,请看这个答案:pure JavaScript equivalent to jQuery's $.ready() how to call a function when the page/dom is ready for it。
简而言之,它说:
document.addEventListener('DOMContentLoaded', fn, false);
window.addEventListener('load', fn, false );
document.attachEvent("onreadystatechange", fn);
window.attachEvent("onload", fn);