문제

How can I determine the index of an <input> element inside the form...

Why do I want to do this?

It'll help me give error codes in the backend and using the error code, I can use JQuery to automatically update the error message beneath the form <input> field using <small> tag (used for errors in zurb-foundation) and make same code scalable to all pages.

Obviously, I'll design error codes in the backend according to the place value in question...

도움이 되었습니까?

해결책

Use selector1.index(selector2), e.g.

$('#myform input').index($('#myinput'))

Fiddle: http://jsfiddle.net/7K22B/

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top