Skip to content Skip to sidebar Skip to footer

Iterate Through All Form Elements Irrespective Of Their Type

I am busy with a form manager for one of our clients. The general idea is that forms will be built for the individual departments and I want to create a micro system which will han

Solution 1:

Use the jQuery :input selector:

jQuery("form :input");

Description: Selects all input, textarea, select and button elements.

http://api.jquery.com/input-selector/

Solution 2:

Try this:

//loop through all input elements
$("form :input").each(function(){
    var thevalue = $(this).val();//the value of the current input elementvar thename = $(this).attr('name');//input namevar thetype = $(this).attr('type');//input type
});

Post a Comment for "Iterate Through All Form Elements Irrespective Of Their Type"