Home > DeveloperSection > Forums > Jquery to check if an input has a specific name?
F Scott Fitzgerald
F Scott Fitzgerald

Total Post:29

Points:203
Posted on    October-05-2013 9:12 AM

 JQuery JQuery 
Ratings:


 1 Reply(s)
 1217  View(s)
Rate this:

Is there any function to check if an input has a specific name in jquery, like we check the existense of a class using hasClass()?

For example if I have an input

<input type="checkbox" class="col_control" checked="checked" name="sr_column" data-columnno="0" />

So that I can check hasName("sr_column") and it returns true



C G E Mannerheim
C G E Mannerheim

Total Post:29

Points:203
Posted on    October-05-2013 9:31 AM

You should use below line of code: -

var name = $("#id").attr("name");

OR

var name = $("#id").prop("name"); 
if(name=="sr_column")
{
   Write here code
}


Don't want to miss updates? Please click the below button!

Follow MindStick