There is a form with 10 elements, there the types of the inputs are all different, and here’s how I can’t figure out how to select all the input types except the file and submit types.

var cntInp = $('form#lala').find('input[type!="file"]').length; console.log(cntInp )// Выводит все инпуты с типами кроме file. 

And how to add to the condition, what else would the throw with input type be?

    1 answer 1

     inputs = Array.from(document.querySelectorAll('input')); inputs.forEach(function(e, i) { if(e.type == 'file' || e.type == 'submit') console.log(e.id, e); }); 
     <input id='1' type='text'> <input id='2' type='checkbox'> <input id='3' type='radio'> <input id='4' type='file'> <input id='5' type='hidden'> <input id='6' type='password'> <input id='7' type='submit'> <input id='8' type='button'> <input id='9' type='range'> <input id='10' type='number'> 

    jquery

     inputs = $('input').not(':input[type=file], :input[type=submit]'); inputs.each((i, e) => { console.log(e.id); }); 
     <script src='https://code.jquery.com/jquery-3.1.0.min.js'></script> <input id='1' type='text'> <input id='2' type='checkbox'> <input id='3' type='radio'> <input id='4' type='file'> <input id='5' type='hidden'> <input id='6' type='password'> <input id='7' type='submit'> <input id='8' type='button'> <input id='9' type='range'> <input id='10' type='number'> 

    • This line is enough inputs = $ ('input'). Not (': input [type = file],: input [type = submit]'); )) - user190134
    • I did not set minus joxi.ru/zAN5dVZsNkpg29 - user190134