jQuery overall element index

http://api.jquery.com/index/

Is there a way to use jQuery index() method to find the index of an element related to the overall document?

I mean, if I have a bunch of img tags in a document, is there a way to know, regardless of their position in the document, their index?

example :

<body>
<img />
<div>
   <img />
   <div>
      <img />
   </div>
</div>
</body>

I've tried using $(window), $(body), $(document), but they all fail. I really need the overall index of the element.

Cheers!

Answers


index() returns the position in a given collection:

$('img').index('id');

Do you mean

$('img').index(imgElement);

or

$('*').index(imgElement);

?


$('*').index($('.someClass'))


Need Your Help

sorting vector with 3D points by a coordinate value -- syntax

c++

I want to sort points_vec vector as shown in the pseudocode below. I want to sort this vector, by a coordinate value like x or y or z

In CXF, is there a way to program the configuration of a client programmatically?

java spring web-services cxf

I have a project that contains web services and also a web service client. I want to configure the web service client without effecting the web services. How can I do this?