Consider following code snippet:

<div>
    <p>Something_1</p>
    <p>Something_2</p>
    <p>Something_3</p>
    </div>
    <script>
        $('p').first().css('color','blue');
    $('p').slice(1,3).css('color','red');
    $('p').slice(-2).css('color','green');
    $('p').closest("div").children().last().css('color','red');
</script>
What will be the color of the text after executing the code?
Explanation
.first() method returns the first element in that set. .last() method returns the last element in that set. .slice() method return a limit set of elements in that set. .closest() method the first ancestor of the selector elements.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести