jQuery selector question (how to select all input fields on a form EXCEPT buttons and checkbox)

前端 未结 2 1955
醉话见心
醉话见心 2021-01-03 17:47

I am trying to select all input fields on a form (except buttons and checkboxes).

I have got as far as to select all the form input elements on a form with id \"myfo

2条回答
  •  长发绾君心
    2021-01-03 18:42

    You can use :not() combined to :checkbox and :button selectors:

    $("#myform :input:not(:button):not(:checkbox)");
    

    and test it with success with the example provided in the documentation of :input

    EDIT: :input also selects textarea, select, button and input[type="hidden"] according to documentation (and a useful example)

提交回复
热议问题