How to select an element by name using jQuery?

element by name

Selecting the element by name using jQuery is to “select some elements and do something with them.” Here we will learn to use the name attribute selector to target an element or you can say we can perform select an element by name using jQuery.

Selecting Elements by Attribute

$( "input[name='first_name']" );

Some more examples:
To select a div tag with the name “name1”, use the following code snippet

$('td[name="td_col1"]')   // Matches exactly 'td_col1'

$('td[name^="td_col"]' )  // Matches those that begin with 'td_col'

$('td[name$="td_col"]' )  // Matches those that end with 'td_col'

$('td[name*="td_col"]' )  // Matches those that contain 'td_col'

You can get more details about this topic from here.
To get to know more about other JQuery topics, you can check these articles too.

Please follow and like us:

Related Posts

Leave a Reply