Jquery to check if an input has a specific name?

Total Post:28

Points:196

JQuery 
 2132  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. 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

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.