Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find input element id by value?

How do I get the id of an input element based on its value? The values will always be unique and there are only seven of them. I have tried this:

$('#wrapper').find("input[value='"+value+"']").each(function(){
    return this.id;
});

But nothing is returned!

like image 455
Abs Avatar asked Dec 05 '22 02:12

Abs


1 Answers

Try

$(this).id nope, this.id works, no need to create a jQuery object for the ID.

or

$(this).attr('id')

HTH

EDIT: This might work:

$('#wrapper').find("input[value='"+value+"']").attr('id');
like image 107
DannyLane Avatar answered Dec 08 '22 00:12

DannyLane