简体   繁体   English

如何使用JavaScript和CSS覆盖模板默认选项

[英]How to override a templates default option with javascript and css

I´m using a template built upon bootstrap. 我正在使用基于引导程序的模板。 It has a sidebar menu which can be toggled clicking on a button with the following code: 它具有一个侧边栏菜单,可以通过单击以下代码来切换按钮:

<a href="javascript:;" class="menu-toggler responsive-toggler" data-toggle="collapse" data-target=".navbar-collapse">

The menu's default state is uncollapsed. 菜单的默认状态为未折叠。 I know the following are very simple questions, but I have almost zero experience with javascript and css, and have not found a way to do it: 我知道以下是非常简单的问题,但是我对javascript和css的经验几乎为零,并且还没有找到解决方法:

How can I call the previous code's functionality upon page load? 如何在页面加载时调用先前代码的功能?

And what exactly is href="javascript:;" 究竟是href =“ javascript :;” calling? 打电话? How does it work? 它是如何工作的?

Thank you. 谢谢。

For a more accurate answer, please provide a link to the template. 要获得更准确的答案,请提供模板链接。

How can I call the previous code's functionality upon page load? 如何在页面加载时调用先前代码的功能?

Try to simulate a click of the link on page load, with something like 尝试模拟页面加载时点击链接的操作,例如

 document.querySelector('.menu-toggler.responsive-toggler').click();

And what exactly is href="javascript:;" 究竟是href =“ javascript :;” calling? 打电话? How does it work? 它是如何工作的?

Apparently, it call javascript code from a link, but I have to say I have never this syntax before. 显然,它从链接中调用javascript代码,但是我不得不说我以前从未使用过这种语法。 In this particuliar case, it cancels the basic anchor functionnality to go to another webpage or id in the page. 在这种特殊情况下,它取消了基本锚功能以转到另一个网页或页面中的id。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM