Jquery to check if an input has a specific name?

Total Post:28

Points:196
JQuery 
 1938  View(s)
Ratings:
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

  1. Post:28

    Points:196
    Re: Jquery to check if an input has a specific name?

    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
    }

      Modified On Mar-31-2018 06:25:28 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!