removeClass with jQuery

1.4k Views Asked by At

I am trying to use the remove class function. My jQuery code is below.

$(document).ready(function() {
    $("div.hidden").removeClass("hidden");
});

HTML

<!DOCTYPE html>
<html>
    <head>
        <title>Testing Page</title>
        <script src="http://code.jquery.com/jquery-latest.min.js"></script>
        <script src="testing.js"></script>
        <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <body>
        <h1 class="hidden">Hello World</h1>
        <div>Dog</div>
        <div class="hidden">Cat</div>
        <div>Girl</div>
    </body>
</html>

It is not working as expected. I expected all divs with the class of hidden to have the class removed thereby causing the divs to be displayed.

CSS

.hidden {
    display: none;
}
1

There are 1 best solutions below

1
On BEST ANSWER

You forgot the jQuery obj to call your selector :

$("div.hidden").removeClass("hidden"); //$(selector);