how to make it so that when clicking on a table cell, a window opens in which the given events would fit in and it was saved in localstorage as in the picture, I understand how to record in localstorage , and how to make it so that when you click on another window, it disappears and how to add a window to the cell. main condition cannot use jquery 
- I'm not looking for finished work, just give advice on how you would act in solving this problem - Dimka Rudnik
- I would write the window closing function, and use it on the current window when clicking on another cell - MasterAlex
- Use jQuery. - Dmitriy Simushev
|
1 answer
It is enough to add an id to the window, and in the "onclick" event add the deletion of this window if it is on the page.
var emptyCreateEventWindow = '<div class="create_event" id="openWindow"><div class="event_input_container"><input type="text" placeholder="Событие"><input type="text" placeholder="День, месяц, год"><input type="text" placeholder="Имена уччастников"></div><textarea name="" id="" cols="30" rows="8" placeholder="Описание"></textarea><input type="submit" value="Готово" class="create_event_button "><input type="submit" value="Удалить" class="create_event_button edit-cancel"><div class="close_event">+</div></div>'; function addHandlers(table) { var tds = table.querySelectorAll("td"); for (var i = 0; i < tds.length; i++) { tds[i].onclick = function() { if(document.getElementById('openWindow')) document.getElementById('openWindow').remove(); this.innerHTML = emptyCreateEventWindow; }; } } |