I have a table. In this table have select element. How can I find in which table row is select element, from within the select’s event handler:
$('#selectElemID').live('change', function(){...});
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
EDIT (two years later): Please don’t do it the way I previously described, it is a total waste as table rows already have a
rowIndexproperty, so there’s just no need to compute anything:Demo.
<silliness>This should do it, if you want the row number of the current select element (which is what I understand from the question):
To explain:
means select the closest parent
trof this select element.means select all the previous rows, and get me the length of the returned collection. Increment it by one to get the current row number, because we are at total previous rows + 1.
For more information:
</silliness>