jquery how to get form element types, names and values

前端 未结 5 1675
失恋的感觉
失恋的感觉 2020-12-30 07:34

I know I can get the name/value relationship by using

$(#form).serializeArray();

But is there a way to get the whole enchilada, type, name

5条回答
  •  无人及你
    2020-12-30 08:16

    Can you loop through each input element of the form and use the data you get from there? Something like this:

    $('form input').each(function(i, v) {
        // Access like this:
        //   $(this).attr('type');
        //   $(this).attr('value');
        //   $(this).attr('name');
    });
    

提交回复
热议问题