$('td').prevAll().length will give you an index based on 0 cell
Alternatively, using index() (can pass a DOM element or jQuery object. If the object is jQuery, only the first object in the wrapped set is used)
var cell = $('td');
If I remember correctly, index() will be easier to use in jQuery 1.4 and will allow you to simply call index () on an element wrapped in a jQuery object to get an index, for example
$('td').index() // NOTE: This will not work in versions of jQuery less than 1.4
So for your function
function TestIndexOf(someTD) { return $(someTD).prevAll().length; }
Russ Cam Nov 02 '09 at 20:32 2009-11-02 20:32
source share