How can I shift-select multiple checkboxes like GMail?

后端 未结 13 1078
野趣味
野趣味 2020-11-30 17:33

In GMail, the user can click on one checkbox in the email list, hold down the Shift key, and select a second checkbox. The JavaScript will then select/unselect the checkboxe

13条回答
  •  生来不讨喜
    2020-11-30 17:49

    This is done through fairly simple javascript.

    They keep track of the id of the last checked box and when when another checkbox is checked they use the shiftKey event attribute to see if shift was held while clicking the checkbox. If so they set the checked property of each checkbox in between the two to true.

    To determine when a box is checked they probably use an onclick event on the checkboxes

提交回复
热议问题