Iterate through all form elements irrespective of their type

前端 未结 2 435
渐次进展
渐次进展 2021-01-22 05:20

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

相关标签:
2条回答
  • 2021-01-22 05:53

    Try this:

    //loop through all input elements
    $("form :input").each(function(){
        var thevalue = $(this).val();//the value of the current input element
        var thename = $(this).attr('name');//input name
        var thetype = $(this).attr('type');//input type
    });
    
    0 讨论(0)
  • 2021-01-22 05:56

    Use the jQuery :input selector:

    jQuery("form :input");
    

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

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

    0 讨论(0)
提交回复
热议问题