JQUERY TO CHECK IF AN INPUT HAS A SPECIFIC NAME?

F Scott Fitzgerald

Total Post:29

Points:203
Posted by  F Scott Fitzgerald
JQuery 
 1537  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. C G E Mannerheim

    Post:29

    Points:203
    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
    }

Answer

NEWSLETTER

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