简体   繁体   中英

How to find element value in jQuery

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

使用属性等于选择器

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

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')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM