0

I am trying to get all class call Position $(".Position") and get then find the value that == 4 and then show the id.

<input type="Text" id="#34" value="1" class="Position">
<input type="Text" id="#22" value="2" class="Position">
<input type="Text" id="#37" value="3" class="Position">
<input type="Text" id="#41" value="4" class="Position">

Thanks

2 Answers 2

6

Use the Attribute Equals Selector

alert($("input.Position[value='4']").attr("id"));
Sign up to request clarification or add additional context in comments.

Comments

4

First, you have to take off the '#' from your id's.

<input type="Text" id="34" value="1" class="Position">

Then you can find the input you are looking for with the following selector:

$('input.Position[value=4]').attr('id')

1 Comment

You should put the tag name before any class declarations in the selector - speeds it up. Probably insignificant in this case, but a good practice to get into. $('input.Position[value=4]').attr('id')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.