Using JavaScript to manipulate HTML input (checkbox) elements via type instead of name

后端 未结 7 2121
说谎
说谎 2021-01-04 14:41

I am implementing an HTML form with some checkbox input elements, and I want to have a Select All or DeSelect All button. However, I do not want to rely on the name

7条回答
  •  天命终不由人
    2021-01-04 15:02

    If jQuery is an option you can do this rather easily.

    See the documentation on jQuery selectors. (The last example in the section shows how to do it with radio buttons but just replace that with check boxes.)

提交回复
热议问题