Yuber70 Roshe2021-01-30 21:41:51
Yuber70 Roshe, 2021-01-30 21:41:51

After reloading the page, the function does not work correctly. Why?

Good day to all! Dear experts, please help me solve one problem for a beginner. In the process of learning, I decided to write a small program (the first sign, so to speak). https://github.com/yuberroshe/my-project The program is a simple bookmarking page, i.e. on
mouse hover, a div opens on an event on which a window opens with an input for entering a link to the resource, and after clicking the button, the link is added and the resource is available on it.
I understand that the code leaves much to be desired, much better, but it works. Works exactly until the page is reloaded.
Those. all links added before reloading the page work, but it is not possible to add new ones (the input window does not open), although the function works (console.log outputs data). It seems to me that the condition on which the function should be launched does not work. Those. for the first time, before adding to localStorage, it works, but after, for some reason I don’t understand, it doesn’t. Hope you can help figure it out. Thank you.

There is a second version of this program. - https://github.com/yuberroshe/my-project . APP3.
I wrote this solution.
if (target && target.classList.contains('block')) {


}. Well, at least somehow it works. Well, there must be at least some success.
And it is necessary in my case
if (target && target.classList.contains('one')) {

}. But div1 is not visible to this function. Tried to display in the global scope, does not exit.
If it's not difficult for you and there is free time, please help with a solution. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
dmitry-toster, 2021-01-30

1. it is not clear what you are using for target == item
2. it is localStoragenot customary to store html layout in
3. what is it bl? this variable is not declared anywhere
4. you do not need to add a class showwhen you have already deleted the class hide
5. after returnthat there should not be any code
In general, this can be written easier - when you enter something into the input, the index of the active tab on which you pressed. Further, when you click on the button, the view information will be saved in localStorage index->urland when the page is loaded, the necessary link will be substituted in the desired tab

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question