简体   繁体   中英

How to remove active class on page load?

//remove active tabs on load
function themeslug_enqueue_script() {
?>
<script>
jQuery(window).load(function(){
        jQuery('.tab').removeClass('active_tab');
        jQuery('.tab_content').removeClass('active_tab_content');
});
</script>
<?php
}
add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_script' );//end

I try using the above code to close specific tabs that are normally opened on load. I not sure why it's not working so far. I am using the code on a child theme of the Enfold theme. Any help will be appreciated.

My current URL is CMSDeployed

I see you are trying to use a javascript snippet inside a php function.

That is not going to work.

Php functions are going to be executed on the server while JS functions are going to be run on client side and on the browser.

Everytime you call that PHP function, it is going to print out that javascript snippet or whatever is inside that block.

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