简体   繁体   中英

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:

How can I call the previous code's functionality upon page load?

And what exactly is 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:;" calling? How does it work?

Apparently, it call javascript code from a link, but I have to say I have never this syntax before. In this particuliar case, it cancels the basic anchor functionnality to go to another webpage or id in the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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