CSS
- 3 ответа
- 0 вопросов
2
Вклад в тег
<button>OK</button> на <button onclick="obr()">OK</button>
(function() {code}()) на function obr(){}
<button type="button" data-id="about" class="js-item-link is-active">
<span>Дата</span>
</button>
<button type="button" data-id="works" class="js-item-link">
<span>Время</span>
<span>13:00 (МСК)</span>
</button>
</div>
<div class="modal-buy-card__tab-container">
<div class="tab_content is-active" id="about">
<input class="modal-buy-card__date-calendar flatpickr flatpickr-input active" type="text" readonly="readonly">
<div>
<button>отмена</button>
<button onclick="obr()">OK</button>
</div>
</div>
<div class="tab_content" id="works">
<p>Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works WorWorks Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works Works</p>
</div>
</div>
<script type="text/javascript">
function obr(){
alert("проверка кнопки!_!")
let tabMenus = document.querySelectorAll('.js-item-link');
let tabContents = document.querySelectorAll('.tab_content');
for (var i = 0; i < tabMenus.length; i++) {
tabMenus[i].addEventListener('click', function(e) {
e.preventDefault();
for (var i = 0; i < tabMenus.length; i++) {
tabMenus[i].className = 'js-item-link';
}
this.className = 'js-item-link is-active';
for (var i = 0; i < tabContents.length; i++) {
tabContents[i].className = 'tab_content';
}
document.getElementById(this.dataset.id).className = 'tab_content is-active';
});
}
};
</script>
<div id="scr"style="height:15%;overflow:scroll;">
<p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p><p>ds</p>
<script>
// document.addEventListener('keydown', function(event) {
// console.log(event)
// });
let speed = 100
let sid = document.getElementById("scr")
document.addEventListener('keydown', function(event) {
//console.log(event)
if(event.key == "ArrowUp"){
sid.scrollBy(0,-speed)
}
if(event.key == "ArrowDown"){
sid.scrollBy(0,speed)
}
});
</script>