Consider following code:

<body>
    <script>
        $elem = $(".cRed");
        $elem.addClass("cBrown").removeClass(".cRed");
    </script>
    <div class="cRed cBlue">Something</div>

    <script>
        $elem = $(".cRed");
        $elem.toggleClass("cBlue cBrown");
        $elem.toggleClass("cRed  cBrown");
    </script>

</body>
What classes will be added to <div> element after the page fully loaded?
Explanation
   
 $elem = $(".cRed");
    $elem.addClass("cBrown").removeClass(".cRed"); // will do nothing, because there is no div element at that moment.
//and
    $elem.toggleClass("cBlue cBrown"); // add class "cBlue cBrown"
    $elem.toggleClass("cRed  cBrown"); // remove (toggle) class

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты