Skip to content Skip to sidebar Skip to footer

Javascript Selecting Form Elements Using Name Attribute

Is it possible to select a form element using it's name attribute? For example if I had something like this: How would I go about se

Solution 1:

Your almost there

var name_val = $('input[name=my_element]').val();

Solution 2:

var name_val = $('input[name="my_element"]').val();

Solution 3:

The following should work:

var name_val = $('input[name="my_element"]').val();

Solution 4:

It's even more simple: $("#form_id").elements["my_element"]


Post a Comment for "Javascript Selecting Form Elements Using Name Attribute"