許瑄芠
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 🗞 9/3(五) todolist 刪除全部&優化 ###### tags: `JavaScript 必修篇 - 前端修練全攻略` 本日對應章節為:todolist 待辦事項、陣列資料操作、箭頭函式基本寫法。 ## 觀念補充 ### 鍵盤事件 - keyup 鍵盤事件 keyup 可以拿來偵測是否按下特定鍵盤,而 keyup 的觸發時機為當你按下特定鍵盤又放開的那刻: ```html= <input type="text"> ``` ```jsx= //透過 querySelector 選取 input 欄位 const input = document.querySelector('input'); //註冊監聽 input 欄位的 "keyup" 事件 input.addEventListener("keyup", function (e) { console.log(e); }); ``` 當我點擊 Enter 鍵觸發該 "keyup" 事件時,可以觀察到 Event 包含: ![](https://i.imgur.com/oyay5UJ.png) 該 "keyup" Event 內相當多的屬性,如果我們希望點擊到 Enter 時,可以觸發對應事件,可以透過以下方式: ```jsx= //註冊監聽 input 欄位的 "keyup" 事件 input.addEventListener("keyup", function (e) { //如果屬性的 key 值為 "Enter" if (e.key === "Enter") { //符合條件就執行大括號內程式碼 console.log('我鍵盤按了 Enter ') } }); ``` 想多了解鍵盤事件怎麼觸發,可以點擊此 [CodePen 檔案](https://codepen.io/denilsonsa/pen/epmoma)。 ## 問題 此為最終關卡任務,為了給同學更多實作空間,此次會縮減步驟指引,改以大方向提示的方式唷! 請同學 fork 此 👉 [ CSS 範本](https://codepen.io/hexschool/pen/KKmvpPP?editors=0010),或使用已實現其他功能之 todoList ,今天要實作刪除全部&優化: ![](https://i.imgur.com/7xKc9zc.png) 重點提示: * 監聽點擊清除已完成項目按鈕 * 點擊後刪除已完成項目(可透過 filter 篩選出未完成項目後重新渲染) * 優化:鍵盤事件 Enter 也能新增待辦事項 * 可透過監聽鍵盤事件 * 鍵盤按下 Enter 後呼叫新增待辦事項函式 如果真的想不出來卡關了,也不要灰心,這裡有可愛的 Vtuber 艾拉的 👉 [todoList 教學](https://courses.hexschool.com/courses/202011122/lectures/34213327) 一天實作一點小功能,很快就完成囉!ヽ(✿゚▽゚)ノ 今天的範例投稿有兩份唷,在寫 Code 時,其實沒有所謂的標準解答,卡關時可以參考別人的程式碼,並融會貫通出自己的寫法唷! ## 回報流程 將答案寫在 CodePen 複製 CodePen 連結貼至下方作業投稿區中回報就算完成了喔! ## 作業投稿區(學員自行投稿) 1. [範例投稿一](https://codepen.io/jmkhsutp/pen/yLXYKJr?editors=0011)、[範例投稿二](https://codepen.io/WangShuan/pen/poeLoyp?editors=0010)(可點此連結觀看解答) 2. [shoppingq](https://codepen.io/shoppingq/pen/mdwrEMe) 3. [Yunei](https://codepen.io/Yunei/pen/eYRJMGw) 4. [Allen Lin](https://codepen.io/lcf7891/pen/mdwEppx) 5. [小韭菜](https://codepen.io/jhang-jhe-wei/pen/GREqxEq) 6. [肉鬆](https://codepen.io/klrkicog/pen/JjJKvrb) 7. [Jane Lin](https://codepen.io/as60160/pen/qBjbQrO) 8. [LMY](https://codepen.io/l_umei/pen/OJgNqgg) 9. [中年大叔](https://codepen.io/adens123/pen/qBjbJwe) 10. [詠銓](https://codepen.io/GGfish26/pen/wveGMjL?editors=0010) 11. [InchI](https://codepen.io/inchik-the-styleful/pen/VwWavNW?editors=0001) 12. [佳鈴](https://codepen.io/zpyfpsxa/pen/bGReMBx?editors=0010) 13. [AmberCYT](https://codepen.io/amberTing/pen/VwWjgBq?editors=1011) 14. [wind](https://codepen.io/wind7y/pen/eYRJaMr) 15. [Rain Liao](https://codepen.io/billpop741/pen/mdmYewW) 16. [黃士桓](https://codepen.io/shr-huan-huang/pen/JjJboLG) 17. [Howard](https://codepen.io/yawdnhbm/pen/gORLbye) 18. [DoraYu](https://codepen.io/dora-yu/pen/gORLwLW?editors=1010) 19. [Sandy](https://codepen.io/Sandy_L/pen/BaZjxVX?editors=0011) 20. [yojanni](https://codepen.io/unayo/pen/YzQWNGP?editors=1010) 21. [curry](https://codepen.io/Ted19851223/pen/VwWPGYJ) 22. [colinhyun](https://codepen.io/colinhyun/pen/wvegzgd) 23. [Hedy](https://codepen.io/babogooyache/pen/bGRpvjM) 24. [皮皮](https://codepen.io/super-shrimp/pen/oNwBdJj?editors=1011) 25. [Wei](https://codepen.io/tartle120/pen/OJgWbyv) 26. [peter](https://codepen.io/peter_hung/pen/gORvqXd) 27. [Joy Cheng](https://codepen.io/joycheng5432/pen/abwqgvE?editors=0011) 28. [Eileen](https://codepen.io/Eileen-Ching/pen/GRExJJy?editors=0011) 29. [ Margo](https://codepen.io/MargoMin/pen/xxrazov?editors=0010) 30. [Joe Kuo](https://codepen.io/alertislow/pen/vYZVNdm) 31. [肉魚](https://codepen.io/zoechen13/pen/RwgYapP?editors=1011) 32. [Tina Yen](https://codepen.io/tlorfrnl-the-typescripter/pen/PoJGdyp?editors=0010) 33. [Sunny](https://codepen.io/Sunny0509/pen/xxXEwGX?editors=1011) 34. [BrunoYu](https://codepen.io/bruno-yu/pen/YzrVMzr?editors=0000) 35. [int Huang](https://codepen.io/intHuang/pen/JjpKWzb?editors=0011) 36. [Peihan Wang](https://codepen.io/PeihanWang/pen/WNMpygy?editors=1111) 37. [Min](https://codepen.io/minnn7716/pen/zYREoLR) 38. [Cliff](https://codepen.io/Cliff_hex/pen/qBopRmd) 39. [CookieSSS](https://codepen.io/sqhjikpa-the-selector/pen/KKoRaeX?editors=1011) 40. [Alex](https://codepen.io/datsxzqg-the-selector/pen/MWGLmXZ?editors=1011) 41. [qoq77416416](https://codepen.io/qoq77416416/pen/oNyzagw?editors=1011) 42. [SASIMI](https://codepen.io/sashimi1327/pen/NWzzmMr) 43. [yunifer](https://codepen.io/yunifer1227022/pen/mdGeJLb?editors=1111) 44. [wei](https://codepen.io/Wei-the-sasster/pen/RwOgqyL?editors=1011) 45. [qqorzi](https://codepen.io/qqorzi/pen/QWXepZP) 46. [yuhao](https://codepen.io/tqdtaouh-the-styleful/pen/GgRvxJp?editors=1011)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully