돌아가기
이 글은 다음 언어로만 작성되어 있습니다. عربي, English, Español, 日本語, Русский, 简体中文. 한국어 번역에 참여해주세요.

Selectable list

중요도: 5

Create a list where elements are selectable, like in file-managers.

  • A click on a list element selects only that element (adds the class .selected), deselects all others.
  • If a click is made with Ctrl (Cmd for Mac), then the selection is toggled on the element, but other elements are not modified.

The demo:

P.S. For this task we can assume that list items are text-only. No nested tags.

P.P.S. Prevent the native browser selection of the text on clicks.

샌드박스를 열어 정답을 작성해보세요.