I have a page with multiple forms within it.
What I want is, obtain the form #, (eg second form is form #2) in which the end user has selected some text
I will use the form # to do some further operations on that specific form, using jquery and i need form # to be passed as parameter to the jquery calls that I have to make.
Is there some way to obtain this using jquery or javascript?
You can use the
index()method to find the # of the form:Format:
$element. index(selector)(where$elementis a jQuery object, and selector is a string which matches the collection to search in).$collection.index($element)(where$collectionis a jQuery object, representing all elements, and$elementis either a DOM or jQuery object, representing the element to look for.Note: The parameter of the
index()is very important. Have a close look at the documentation if you’re not sure about it.