My page is dynamically generating the body class, and it's some WordPress plugin generating. I wanted to easily remove that class, so figured I could strip with jQuery. I thought this would remove the class "page" from the body code which ends up looking like:
<body class="page otherattr otherattr2 etc etc">
By using this jquery in my footer:
<script type="text/javascript">
$(document).ready(function(){
$("body").removeClass("page");
});
</script>
But it doesn't seem to work, am I missing something?
jQuery hide() Method The hide() method hides the selected elements. Tip: This is similar to the CSS property display:none.
jQuery is a lightweight, "write less, do more", JavaScript library. The purpose of jQuery is to make it much easier to use JavaScript on your website. jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code.
Similarly, you can remove the classes from the elements using the jQuery removeClass() method. The removeClass() method can remove a single class, multiple classes, or all classes at once from the selected elements.
removeClass() method: This method removes a class in the selector element in jQuery.
$(document).ready(function(){
jQuery(window).load(function () {
$("body").removeClass("page");
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With