Conversation
Xinhe998
reviewed
Feb 1, 2020
| $space-size: 15px; | ||
|
|
||
|
|
||
| $pic-unchecked: "../images/circle.png"; |
Xinhe998
reviewed
Feb 1, 2020
| <h3 class="form__title">Todos</h3> | ||
| <input placeholder="Type your task" id="input" class="form__input" type="text"> | ||
| </form> | ||
| <iframe src="" name="invisible" class="form__target" frameborder="0"></iframe> |
Author
There was a problem hiding this comment.
因為我的input是用form包住,但form送出後會自動刷新,所以要新增的todo就不會暫存在下面,會被刷新掉。
然後這是網路上查到的防止form刷新,就是把form的target設為iframe,讓iframe去提交新增~
Owner
There was a problem hiding this comment.
因為用form+action就會有這樣的效果~
如果想要避免可能要用 event.preventDefault()
或者參考我的寫法~
https://github.com/Xinhe998/javascript-todolist
Xinhe998
reviewed
Feb 1, 2020
| @@ -0,0 +1,49 @@ | |||
| var input = document.getElementsByClassName("form__input"); | |||
Owner
There was a problem hiding this comment.
這裡可以直接用 getElementById 就好,這樣 line4 就可以不用寫成 input[0]
Xinhe998
reviewed
Feb 1, 2020
| @@ -0,0 +1,49 @@ | |||
| var input = document.getElementsByClassName("form__input"); | |||
| var list = document.getElementById("js-list"); | |||
| var d = 0; | |||
Xinhe998
reviewed
Feb 1, 2020
| var text = document.createElement("span"); | ||
| var all_list = list.children; | ||
| text.append(todo); | ||
| text.setAttribute("class","list__text"); |
Owner
There was a problem hiding this comment.
大家比較常會寫成 text.classList.add('list__text');
Owner
|
用scss很棒👍🏻 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
我是APPLE,學姊這是我的作業,再麻煩你過目了~