I am trying to get DOM element from jQuery selector array.
var n = $(this).index();
$title = $(".title:not(.small)")[n];
Yet it only returns text and not DOM element as I want it to. I want to get DOM element so i can get the elements position on the page and scroll to it.
$(this) = list element .title = there are few elements on the page with class="title" and "title small".
Thank you
PS: I could not find anything similar on stackoverflow or anywhere on google. It could be that I don't know how to correctly google this "error".
$(".title:not(.small)")[n]
will return DOM element not jQuery object. You can use eq()
method like following.
var n = $(this).index(),
$title = $(".title:not(.small)").eq(n);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.