помогите доделать скрипт верт календаря
как в этот скрипт вставить поле ввода и кнопки - + которые добавят/отнимут один год от введённого в инпут, и кнопку сегодня при клике на которую год в поле ввода вернется к текущему?
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style> body { display: flex; flex-wrap: wrap; justify-content: space-between;} .day { border: 1px solid #ccc; width: 30px; line-height: 30px; text-align: center; margin: 1px; background-color: hsl(210,100%,90%); color: hsl(210,100%,50%); } .month { height: 220px; margin: 5px; border: 1px solid #ccc; border-radius: 4px; } .month tr:nth-child(n + 7) td.day{ background-color: hsl(348,100%,90%); color: hsl(348,100%,50%); } .month tr:nth-child(1) th{ text-align: center; } </style> </head> <body> <table> <tr><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td></tr> </table> <script> var calendar = { update: function(year, month) { this.year = year; this.month = ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'][month]; var startDay = new Date(year, month, 1); var offsetDay = (startDay.getDay()||7) - 1; startDay.setDate(startDay.getDate() - offsetDay); var lastDay = new Date(startDay); var days = (new Date(year, month + 1, 0)).getDate(); days = Math.ceil((days + offsetDay)/ 7) * 7; lastDay.setDate(lastDay.getDate() + days); this.data = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс']; while (startDay < lastDay) { this.data.push(startDay.getDate()); startDay.setHours(24); } }, render: function() { var html = ['<tr>','<tr>','<tr>','<tr>','<tr>','<tr>','<tr>']; for (var i = 0; i < this.data.length; i++) { html[i % 7] += '<td class="day">' + this.data[i] ; } var title = '<tr><th colspan=7>' + this.month; this.element.innerHTML = title + html.join(''); } }; var thisYear = 2021; for (var i = 0; i < 12; i++) { var table = document.createElement('table'); table.className = 'month'; calendar.element = table; calendar.update(thisYear, i); calendar.render(); document.body.appendChild(table) } </script> </body> </html> |
S O S
|
календарь по годам
Блондинка,
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style> .content { display: flex; flex-wrap: wrap; justify-content: space-between; } .content h3 { width: 100%; text-align: center; } .day { border: 1px solid #ccc; width: 30px; line-height: 30px; text-align: center; margin: 1px; background-color: hsl(210, 100%, 90%); color: hsl(210, 100%, 50%); } .month { height: 220px; margin: 5px; border: 1px solid #ccc; border-radius: 4px; } .month tr:nth-child(n + 7) td.day { background-color: hsl(348, 100%, 90%); color: hsl(348, 100%, 50%); } .month tr:nth-child(1) th { text-align: center; } </style> </head> <body> <button class="btn year" data-up='1'>+1</button> <button class="btn year" data-up='-1'>-1</button> <div class="content"></div> <script> var calendar = { update: function(year, month) { this.year = year; this.month = ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'][month]; var startDay = new Date(year, month, 1); var offsetDay = (startDay.getDay() || 7) - 1; startDay.setDate(startDay.getDate() - offsetDay); var lastDay = new Date(startDay); var days = (new Date(year, month + 1, 0)).getDate(); days = Math.ceil((days + offsetDay) / 7) * 7; lastDay.setDate(lastDay.getDate() + days); this.data = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс']; while (startDay < lastDay) { this.data.push(startDay.getDate()); startDay.setHours(24); } }, render: function() { var html = ['<tr>', '<tr>', '<tr>', '<tr>', '<tr>', '<tr>', '<tr>']; for (var i = 0; i < this.data.length; i++) { html[i % 7] += '<td class="day">' + this.data[i]; } var title = '<tr><th colspan=7>' + this.month; this.element.innerHTML = title + html.join(''); } }; function createYearCalendar(year, parent) { parent.innerHTML = `<h3>${year}</h3>`; for (var i = 0; i < 12; i++) { var table = document.createElement('table'); table.className = 'month'; calendar.element = table; calendar.update(thisYear, i); calendar.render(); parent.append(table) } } var thisYear = 2021; var parent = document.querySelector('.content') createYearCalendar(thisYear, parent); document.addEventListener('click', function(event) { var target = event.target; if (target = target.closest('.btn.year')) { event.preventDefault(); thisYear += +target.dataset.up; createYearCalendar(thisYear, parent); } }); </script> </body> </html> |
рони,
Цитата:
<div id="calendar"> <div id="navigation_panel"> <button class="year_minus minus">–</button> <input type="text" size="4" id="calendar_year" /> <button class="year_plus plus">+</button><br/> <button id="presently" style="display: none;">сегодня</button> </div> <div class="content"> <table id="table"> <tr><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td></tr> <tr><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td></tr> <tr><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td></tr> <tr><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td></tr> </table></div> </div> и возможно ли разместить месяца в ячейках таблицы с классом td_month, а названия месяцев в блоки с классом month_name |
Блондинка,
:-? ... такое ощущение, всегда второй день обучения по javascript ... |
Блондинка,
далее сами ... |
<!DOCTYPE html> <html lang="ru"> <head> <meta charset="utf-8"> <title></title> <style type="text/css"> @import url('https://fonts.googleapis.com/css?family=Baumans&display=swap'); body { width: 1100px; } body, select, input { font: 14px serif; } #calendar { width: 330px; height: 375px; display: inline-block; border: 1px solid hsl(0,0%,66%); border-radius: 6px/4px; padding: 5px; } #navigation_panel { background-color: hsl(210, 100%, 92%); min-height: 34px; max-height: 78px; border: 1px solid hsl(0,0%,66%); border-radius: 6px/4px; padding: 10px; margin-bottom: 6px; text-align: center; vertical-align: middle; display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center; -webkit-flex-wrap: wrap; flex-wrap: wrap; } #navigation_panel button, #navigation_panel #calendar_year { background-color: hsl(210, 100%, 85%); color: hsl(210, 100%, 45%); font: 14px serif; border: 1px solid hsl(210, 100%, 45%); } #calendar_month { background-color: transparent; color: hsl(210,100%,45%); font: 14px serif; border: 1px solid hsl(210, 100%, 45%); } #navigation_panel button { height: 34px; vertical-align: middle; } #background_month { background-color: hsl(210, 100%, 85%); display: inline-block; } button.minus { width: 28px; text-align: center; border-radius: 12px 0 0 12px / 10px 0 0 10px; margin-right: -1px; } button.plus { width: 28px; text-align: center; border-radius: 0 12px 12px 0 / 0 10px 10px 0; margin-left: -1px; } .month_plus { margin-right: 35px; } #presently { width: 234px; margin-top: 10px; border-radius: 12px/10px;} #calendar_month { width: 89px; display: inline-block; } #calendar_year { width: 54px; display: inline-block; } select { height: 34px; } input { height: 30px; border: 1px solid hsl(0,0%,66%); display: inline-block; text-align: center; } #table { font-family: 'Baumans', cursive; table-layout: fixed; width: 100%; height: 413px; padding: 2px; } #table, td { border: 1px solid hsl(0,0%,66%); border-radius: 6px/4px; } td { margin: 1px; text-align: center; } #table tbody td.prevMonth { background-color: hsl(210,100%,95%); color: hsl(210,100%,80%); border: 1px solid hsl(0,0%,80%); } #table tbody tr:nth-child(n + 6) td.prevMonth { background-color: hsl(348,100%,95%); color: hsl(348,100%,80%); border: 1px solid hsl(0,0%,80%); } .curMonth { background-color: ; } #table tbody td.nextMonth { background-color: hsl(210,100%,95%); color: hsl(210,100%,80%); border: 1px solid hsl(0,0%,80%); } #table tbody tr:nth-child(n + 6) td.nextMonth { background-color: hsl(348,100%,95%); color: hsl(348,100%,80%); border: 1px solid hsl(0,0%,80%); } #presently.hide { display: none; } #table tbody tr td.week-day { background-color: hsl(210,100%,85%); color: hsl(210,100%,50%); border: 1px solid hsl(0,0%,60%); width: 20%; } /* день недели */ #table tbody tr:nth-child(n + 6) td.week-day { background-color: hsl(348,100%,85%); color: hsl(348,100%,50%); border: 1px solid hsl(0,0%,60%); } /* день недели выходной*/ #table tbody tr td.week-day.curDay { border: 1px solid hsl(210,100%,50%); background-color: hsl(210,100%,75%); color: hsl(210,100%,98%); font-weight: bold; text-shadow: 1px 1px hsl(210,100%,50%), -1px 1px hsl(210,100%,50%), 1px -1px hsl(210,100%,50%), -1px -1px hsl(210,100%,50%), 1px 0 hsl(210,100%,50%), 0 1px hsl(210,100%,50%), -1px 0 hsl(210,100%,50%), 0 -1px hsl(210,100%,50%); letter-spacing: 2px; } /* сегодн день недели */ #table tbody tr:nth-child(n + 6) td.week-day.curDay { border: 1px solid hsl(348,100%,50%); background-color: hsl(348,100%,75%); color: hsl(348,100%,98%); font-weight: bold; text-shadow: 1px 1px hsl(348,100%,50%), 1px -1px hsl(348,100%,50%), -1px 1px hsl(348,100%,50%), -1px -1px hsl(348,100%,50%), 1px 0 hsl(348,100%,50%), -1px 0 hsl(348,100%,50%), 0 1px hsl(348,100%,50%), 0 -1px hsl(348,100%,50%); letter-spacing: 2px; } /* сегодн день недели выходной */ #table tbody td { background-color: hsl(210,100%,90%); color: hsl(210,100%,50%); } /* будние дни текущего месяца */ #table tbody tr:nth-child(n + 6) td{ background-color: hsl(348,100%,90%); color: hsl(348,100%,50%); } /* выходные дни текущего месяца */ #table tbody tr td.curMonth.curDay { background-color: hsl(210,100%,80%); border: 1px solid hsl(210, 100%, 50%); font-weight: bold; color: hsl(210,100%,100%); text-shadow: 1px 1px hsl(210,100%,50%), -1px 1px hsl(210,100%,50%), 1px -1px hsl(210,100%,50%), -1px -1px hsl(210,100%,50%), 1px 0 hsl(210,100%,50%), 0 1px hsl(210,100%,50%), -1px 0 hsl(210,100%,50%), 0 -1px hsl(210,100%,50%); letter-spacing: 3px; } /* сегодня будний */ #table tbody tr:nth-child(n + 6) td.curMonth.curDay { background-color: hsl(348,100%,80%); border: 1px solid hsl(348,100%,50%); color: hsl(348,100%,100%); text-shadow: 1px 1px hsl(348,100%,50%), 1px -1px hsl(348,100%,50%), -1px 1px hsl(348,100%,50%), -1px -1px hsl(348,100%,50%), 1px 0 hsl(348,100%,50%), -1px 0 hsl(348,100%,50%), 0 1px hsl(348,100%,50%), 0 -1px hsl(348,100%,50%); letter-spacing: 3px; } /* сегодня выходной */ #calendar { display: flex; flex-direction: column; } .content_month { flex: 1; } #table { height:100%; } button, select, input { outline: none; } </style> </head> <body> <div id="calendar"> <div id="navigation_panel"> <button class="month_minus minus">❮</button> <span id="background_month"><select id="calendar_month"></select></span> <button class="month_plus plus">❯</button> <button class="year_minus minus">❮</button> <input type="number" size="4" id="calendar_year" /> <button class="year_plus plus">❯</button><br /> <button id="presently">сегодня</button> </div> <div class="content_month"> <table id="table"> <tbody></tbody> </table></div> </div> <style type="text/css"> #calendar_Year { width: 996px; padding: 5px; border: 1px solid hsl(0,0%,66%); } #navigation_panel_year { width: 954px; border: 1px solid hsl(0,0%,66%); white-space: nowrap; padding: 10px 20px; margin: 0 0 3px 0; } #table_year { width: 1020px; border: none; margin: 0 0 0 -2px;; padding: 0; } .td_month { width: 330px; height: 375px; border: 1px solid hsl(0,0%,66%); padding: 5px; margin-left: -2px; } div.month_name { border: 1px solid hsl(0,0%,66%); padding: 10px 0;} button.year_minus { background-color: hsl(210, 100%, 85%); width: 28px; height: 34px; text-align: center; border-radius: 12px 0 0 12px / 10px 0 0 10px; margin-right: -6px; } button.year_plus { background-color: hsl(210, 100%, 85%); width: 28px; height: 34px; text-align: center; border-radius: 0 12px 12px 0 / 0 10px 10px 0; margin-left: -6px; } .month_plus { margin-right: 35px; } #presently { width: 234px; margin-top: 10px; border-radius: 12px/10px;} #calendar_month { width: 89px; display: inline-block; } #calendar_year { width: 54px; display: inline-block; } select { height: 34px; } #calendar_year { height: 30px; display: inline-block; text-align: center; } button.year_minus, button.year_plus, #calendar_year { background-color: hsl(210,100%,85%); color: hsl(210,100%,45%); font: 14px serif; border: 1px solid hsl(210,100%,45%); } </style> <div id="calendar_Year"> <div id="navigation_panel_year"> <button class="year_minus">–</button> <input type="number" size="4" id="calendar_year"/> <button class="year_plus">+</button><br/> <button id="presently_year" style="display: none;">сегодня</button> </div> <div class="content_year"> <table id="table_year"> <tr><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td></tr> <tr><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td></tr> <tr><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td></tr> <tr><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td></tr> </table></div> </div> </body> </html> |
рони,
вот твой скрипт календаря на месяц <!DOCTYPE html> <html lang="ru"> <head> <meta charset="utf-8"> <title></title> <style type="text/css"> @import url('https://fonts.googleapis.com/css?family=Baumans&display=swap'); body { width: 1100px; } body, select, input { font: 14px serif; } #calendar { width: 330px; height: 375px; display: inline-block; border: 1px solid hsl(0,0%,66%); border-radius: 6px/4px; padding: 5px; } #navigation_panel { background-color: hsl(210, 100%, 92%); min-height: 34px; max-height: 78px; border: 1px solid hsl(0,0%,66%); border-radius: 6px/4px; padding: 10px; margin-bottom: 6px; text-align: center; vertical-align: middle; display: -webkit-box; display: -webkit-flex; display: flex; -webkit-box-align: center; -webkit-align-items: center; align-items: center; -webkit-box-pack: center; -webkit-justify-content: center; justify-content: center; -webkit-flex-wrap: wrap; flex-wrap: wrap; } #navigation_panel button, #navigation_panel #calendar_year { background-color: hsl(210, 100%, 85%); color: hsl(210, 100%, 45%); font: 14px serif; border: 1px solid hsl(210, 100%, 45%); } #calendar_month { background-color: transparent; color: hsl(210,100%,45%); font: 14px serif; border: 1px solid hsl(210, 100%, 45%); } #navigation_panel button { height: 34px; vertical-align: middle; } #background_month { background-color: hsl(210, 100%, 85%); display: inline-block; } button.minus { width: 28px; text-align: center; border-radius: 12px 0 0 12px / 10px 0 0 10px; margin-right: -1px; } button.plus { width: 28px; text-align: center; border-radius: 0 12px 12px 0 / 0 10px 10px 0; margin-left: -1px; } .month_plus { margin-right: 35px; } #presently { width: 234px; margin-top: 10px; border-radius: 12px/10px;} #calendar_month { width: 89px; display: inline-block; } #calendar_year { width: 54px; display: inline-block; } select { height: 34px; } input { height: 30px; border: 1px solid hsl(0,0%,66%); display: inline-block; text-align: center; } #table { font-family: 'Baumans', cursive; table-layout: fixed; width: 100%; height: 413px; padding: 2px; } #table, td { border: 1px solid hsl(0,0%,66%); border-radius: 6px/4px; } td { margin: 1px; text-align: center; } #table tbody td.prevMonth { background-color: hsl(210,100%,95%); color: hsl(210,100%,80%); border: 1px solid hsl(0,0%,80%); } #table tbody tr:nth-child(n + 6) td.prevMonth { background-color: hsl(348,100%,95%); color: hsl(348,100%,80%); border: 1px solid hsl(0,0%,80%); } .curMonth { background-color: ; } #table tbody td.nextMonth { background-color: hsl(210,100%,95%); color: hsl(210,100%,80%); border: 1px solid hsl(0,0%,80%); } #table tbody tr:nth-child(n + 6) td.nextMonth { background-color: hsl(348,100%,95%); color: hsl(348,100%,80%); border: 1px solid hsl(0,0%,80%); } #presently.hide { display: none; } #table tbody tr td.week-day { background-color: hsl(210,100%,85%); color: hsl(210,100%,50%); border: 1px solid hsl(0,0%,60%); width: 20%; } /* день недели */ #table tbody tr:nth-child(n + 6) td.week-day { background-color: hsl(348,100%,85%); color: hsl(348,100%,50%); border: 1px solid hsl(0,0%,60%); } /* день недели выходной*/ #table tbody tr td.week-day.curDay { border: 1px solid hsl(210,100%,50%); background-color: hsl(210,100%,75%); color: hsl(210,100%,98%); font-weight: bold; text-shadow: 1px 1px hsl(210,100%,50%), -1px 1px hsl(210,100%,50%), 1px -1px hsl(210,100%,50%), -1px -1px hsl(210,100%,50%), 1px 0 hsl(210,100%,50%), 0 1px hsl(210,100%,50%), -1px 0 hsl(210,100%,50%), 0 -1px hsl(210,100%,50%); letter-spacing: 2px; } /* сегодн день недели */ #table tbody tr:nth-child(n + 6) td.week-day.curDay { border: 1px solid hsl(348,100%,50%); background-color: hsl(348,100%,75%); color: hsl(348,100%,98%); font-weight: bold; text-shadow: 1px 1px hsl(348,100%,50%), 1px -1px hsl(348,100%,50%), -1px 1px hsl(348,100%,50%), -1px -1px hsl(348,100%,50%), 1px 0 hsl(348,100%,50%), -1px 0 hsl(348,100%,50%), 0 1px hsl(348,100%,50%), 0 -1px hsl(348,100%,50%); letter-spacing: 2px; } /* сегодн день недели выходной */ #table tbody td { background-color: hsl(210,100%,90%); color: hsl(210,100%,50%); } /* будние дни текущего месяца */ #table tbody tr:nth-child(n + 6) td{ background-color: hsl(348,100%,90%); color: hsl(348,100%,50%); } /* выходные дни текущего месяца */ #table tbody tr td.curMonth.curDay { background-color: hsl(210,100%,80%); border: 1px solid hsl(210, 100%, 50%); font-weight: bold; color: hsl(210,100%,100%); text-shadow: 1px 1px hsl(210,100%,50%), -1px 1px hsl(210,100%,50%), 1px -1px hsl(210,100%,50%), -1px -1px hsl(210,100%,50%), 1px 0 hsl(210,100%,50%), 0 1px hsl(210,100%,50%), -1px 0 hsl(210,100%,50%), 0 -1px hsl(210,100%,50%); letter-spacing: 3px; } /* сегодня будний */ #table tbody tr:nth-child(n + 6) td.curMonth.curDay { background-color: hsl(348,100%,80%); border: 1px solid hsl(348,100%,50%); color: hsl(348,100%,100%); text-shadow: 1px 1px hsl(348,100%,50%), 1px -1px hsl(348,100%,50%), -1px 1px hsl(348,100%,50%), -1px -1px hsl(348,100%,50%), 1px 0 hsl(348,100%,50%), -1px 0 hsl(348,100%,50%), 0 1px hsl(348,100%,50%), 0 -1px hsl(348,100%,50%); letter-spacing: 3px; } /* сегодня выходной */ #calendar { display: flex; flex-direction: column; } .content_month { flex: 1; } #table { height:100%; } button, select, input { outline: none; } </style> </head> <body> <div id="calendar"> <div id="navigation_panel"> <button class="month_minus minus">❮</button> <span id="background_month"><select id="calendar_month"></select></span> <button class="month_plus plus">❯</button> <button class="year_minus minus">❮</button> <input type="number" size="4" id="calendar_year" /> <button class="year_plus plus">❯</button><br /> <button id="presently">сегодня</button> </div> <div class="content_month"> <table id="table"> <tbody></tbody> </table></div> </div> <script> Date.prototype.reduce = function(callback, value) { var year = this.getFullYear(); var month = this.getMonth(); var step = new Date(year, month, 1); var last = new Date(year, month + 1, 0); step.setHours(24 * (0 - ((step.getDay() + 6) % 7))); last.setHours(24 * (6 - ((last.getDay() + 6) % 7))); for (var i = 0; step <= last; i++) { value = callback(value, new Date(+step), i, this); step.setHours(24); } return value; }; var data = new Date(); var selectMonth = document.querySelector('#calendar_month'); var monthNames = [ 'Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь', ]; monthNames.forEach(function(monthName, i) { selectMonth.options[i] = new Option(monthName, i); }); selectMonth.addEventListener('change', function() { data.setMonth(this.value); createCalendar(data); }); var minusMonth = document.querySelector('.month_minus'); minusMonth.addEventListener('click', function() { data.setMonth(data.getMonth() - 1); createCalendar(data); }); var plusMonth = document.querySelector('.month_plus'); plusMonth.addEventListener('click', function() { data.setMonth(data.getMonth() + 1); createCalendar(data); }); var minusYear = document.querySelector('.year_minus'); minusYear.addEventListener('click', function() { data.setYear(data.getFullYear() - 1); createCalendar(data); }); var plusYear = document.querySelector('.year_plus'); plusYear.addEventListener('click', function() { data.setYear(data.getFullYear() + 1); createCalendar(data); }); var inputYear = document.querySelector('#calendar_year'); inputYear.addEventListener('input', function() { if (/^d{4}$/.test(this.value)) { data.setYear(this.value); createCalendar(data); } }); var currentButton = document.querySelector('#presently'); currentButton.addEventListener('click', function() { data = new Date(); createCalendar(data); }); function createCalendar(data) { var now = new Date().setHours(0, 0, 0, 0); var year = data.getFullYear(); inputYear.value = year; var month = data.getMonth(); selectMonth.selectedIndex = month; currentButton.classList.remove('hide'); var indexcurDay; var cls = ['prevMonth', 'curMonth', 'nextMonth'], indexCls = 0; var html = data.reduce(function(value, current, index, source) { var date = current.getDate(); if (date == 1) indexCls++; var className = cls[indexCls]; if (+now == +current && indexCls == 1) { className += ' curDay'; currentButton.classList.add('hide'); indexcurDay = index % 7; } value[index % 7] += '<td class="' + className + '">' + date; return value }, ['<tr><td class="week-day">Пн.', '<tr><td class="week-day">Вт.', '<tr><td class="week-day">Ср.', '<tr><td class="week-day">Чт.', '<tr><td class="week-day">Пт.', '<tr><td class="week-day">Сб.', '<tr><td class="week-day">Вс.']); document.querySelector('#table tbody').innerHTML = html.join(''); var daysTd = document.querySelectorAll('.week-day'); if(indexcurDay !== void 0) daysTd[indexcurDay].classList.add('curDay'); } createCalendar(data); var timer; function refresh() { window.clearTimeout(timer); var finish = new Date().setHours(24, 0, 0, 0); finish -= data; timer = window.setTimeout(function() { createCalendar(data); refresh(); }, finish); } refresh(); </script> </div> </body> </html> |
возможно ли в него добавить ссылку, при клике на которую, html-код страницы станет таким
<style type="text/css"> #calendar_Year { width: 996px; padding: 5px; border: 1px solid hsl(0,0%,66%); } #navigation_panel_year { width: 954px; border: 1px solid hsl(0,0%,66%); white-space: nowrap; padding: 10px 20px; margin: 0 0 3px 0; } #table_year { width: 1020px; border: none; margin: 0 0 0 -2px;; padding: 0; } .td_month { width: 330px; height: 375px; border: 1px solid hsl(0,0%,66%); border-radius: 0px/0px; padding: 5px; margin-left: -2px; } div.month_name { border: 1px solid hsl(0,0%,66%); padding: 10px 0;} button.year_minus { background-color: hsl(210, 100%, 85%); width: 28px; height: 34px; text-align: center; border-radius: 12px 0 0 12px / 10px 0 0 10px; margin-right: -6px; } button.year_plus { background-color: hsl(210, 100%, 85%); width: 28px; height: 34px; text-align: center; border-radius: 0 12px 12px 0 / 0 10px 10px 0; margin-left: -6px; } .month_plus { margin-right: 35px; } #presently { width: 234px; margin-top: 10px; border-radius: 12px/10px;} #calendar_month { width: 89px; display: inline-block; } #calendar_year { width: 54px; display: inline-block; } select { height: 34px; } #calendar_year { height: 30px; display: inline-block; text-align: center; } button.year_minus, button.year_plus, #calendar_year { background-color: hsl(210,100%,85%); color: hsl(210,100%,45%); font: 14px serif; border: 1px solid hsl(210,100%,45%); } </style> <div id="calendar_Year"> <div id="navigation_panel_year"> Календарь на <button class="year_minus">–</button> <input type="number" size="4" id="calendar_year"/> <button class="year_plus">+</button> год. <br/> <button id="presently_year" style="display: none;">сегодня</button> </div> <div class="content_year"> <table id="table_year"> <tr><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td></tr> <tr><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td></tr> <tr><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td></tr> <tr><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td><td class="td_month"><div class="month_name"></div></td></tr> </table></div> <a>календарь на месяц</a>и отобразится календарь на год, а при клике на ссылку "календарь на месяц опять вернулся к отображению месяца? |
другими словами, при клике на ссылку "календарь на год" пропадёт выпадающий список для выбора месяца, с кнопками - и + месяц, а вместо списка появится текст "календарь на <button>-</button><input/><button>+</button> год."
|
Часовой пояс GMT +3, время: 05:53. |