jQueryth-child() Selector Question.

Asked 2 years ago, Updated 2 years ago, 100 views

$('div:nth-child(2)').css ('background', 'red') applied. div I tried to apply it to my second child, I don't know why it applies to all children except section data-role=header

$('div:nth-child(1)').When running css('background', 'red') The first child of div It applies well to id=dee2.

jquery selector html

2022-09-22 10:34

1 Answers

When CSS instructs div:nth-child(2), what does the browser do to select?

In the given code, $('div:nth-child(2)) is kept by #dee1 and #dee3. Why? Because #dee1 is the second element under the parent section[data-role=page] and #dee3 is the second element under the parent #div1. Give a little transparency to the background and you'll understand the situation better.

Find out more.


2022-09-22 10:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.