Как получить идентификатор всех входов внутри формы?

Как получить весь идентификатор входных элементов внутри формы в массиве?

Ответ 1

Что-то вдоль линий...

<script src="../../Scripts/jquery-1.4.2.min.js"></script>

<script type="text/javascript">

    $(document).ready(function ()
    {
         // Get all the inputs into an array...
         var $inputs = $('#myForm :input');

         // An array of just the ids...
         var ids = {};

         $inputs.each(function (index)
         {
             // For debugging purposes...
             alert(index + ': ' + $(this).attr('id'));

             ids[$(this).attr('name')] = $(this).attr('id');
         });
    });


</script>

Ответ 2

$ids = $('#myform input[id]').map(function() {
  return this.id;
}).get();

Ответ 3

Вы можете сузить свой поиск с помощью более точного выбора: ввод формы и селектор атрибутов для тех, у которых есть идентификатор

$(document).ready(function() {
    $('form input[id]').each(function() {
        formId.push(J(this).attr('id'));
});
});