Consider following code snippet:

    <p class="foo">Something_1</p>
    <p class="bizz foo">Something_2</p>
    <p class="foo bizz">Something_3</p>
What will be the colors of the <p> elements?
Unlike other filtering methods, .is() does not create a new jQuery object. Instead, it allows you to test the contents of a jQuery object without modification.

    $('div').has('p').css('color','red'); // make all p elements to be red
    $('p').is('.foo').css('color','green'); // Uncaught TypeError and will stop the code execution
That is why all <p> elements will have red color.

Следи за CodeGalaxy

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

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