Wednesday, April 15, 2015

How to get element with its name attribute by using jQuery?

In jQuery, it use # to get id attribute  and . to get  class attribute.

For example, in the jQuery code like this,


 $("#classtable").on("click",".removebutton",function ()  

It will get the attribute from HTML below.

 <table id="classtable" class="table table-striped">  
 ...  
 <button type="button" class="removebutton" title="Remove this class">  
 .....  
 <input type="text" id="displayName" name="displayName" >  

But for the name attribute, we have to use this way:

$('[name="displayName"]').dosomthing();

No comments:

Post a Comment