I was wondering, I know that $(selector) returns a jQuery object, but say I have a series of div in the body such as:
<body>
<div> </div>
<div> </div>
<div> </div>
</body>
When I try $(“div”), jQuery should return a jQuery object that is like an array of divs, BUT when I try to specify a certain div like $(“div”)[1], is this not a jQuery object? And if it isn’t, I know I can’t use .css() so how can I change the css of a specific div that I need to be determined dynamically?
$("div")returns an array of DOM elements.$("div")[1]gets the 2nd element on the page, as a DOM element. To make it back into a jQuery object, you can do$($("div")[1]).I don’t suggest you do that though. You can use the
:eq()selector to get the div you want.Or, you can use the
.eq()function.