Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get html element by name in jquery?

I know the selector used for name is $('input[name=xyz]') but what if I have a condition ex.

 if (input.is("[name=listItem,GrdFromDateTime,GrdToDateTime,GrdRemarks]"))

how can I achieve this?

Thanks in Advance :)

like image 780
R K Sharma Avatar asked Dec 18 '22 21:12

R K Sharma


1 Answers

Keep the names in an array and check if the current input name attribute is in the array.

var names = ["listItem", "GrdFromDateTime", "GrdToDateTime", "GrdRemarks"];

if(names.indexOf(input.attr('name')) !== -1) {
like image 112
Tushar Avatar answered Dec 21 '22 10:12

Tushar