мучаюсь второй день
document.getElementById('player').addEventListener('ended', function() {
alert('The end!');
}, false);
это я к тому, что аккордеон вроде не подходитПодходит
$('dt').click(function() {
$(this).next().slideToggle( "slow" );
});
.scroll-left {
overflow-x: scroll;
width: 100vw;
}
document.querySelector('bottom').addEventListener('click',function(){
document.querySelector('div').classList.toggle('scroll-left');
// или .classList.add('scroll-left'); для разовой операции
}, false);
document.addEventListener('DOMContentLoaded', function() {
var li = document.querySelectorAll('li');
li[Math.floor(Math.random() * li.length)].style.display = 'list-item';
}, false);
$(function() {
var li = $('li');
li.eq(Math.floor(Math.random() * li.length)).show();
});
if (данные счетчика хранятся в БД || файле ) {
отправляем ajax-запрос || обычный запрос на сервер;
увеличиваем значение на 1 в хранилище;
} elseif (счетчик для каждого клиента свой && данные необходимо хранить на клиенте) {
используем localStorage/sessionStorage || cookie;
} else {
// а тут бы неплохо уточнить, что и как у вас построено
}
Если же техническая сторона вопроса, то рассказывайте, что не получается var fakeBg = $('#fake_bg').height($(document).height());
$(window).on('scroll', function(){
fakeBg.css('margin-top', -$(this).scrollTop());
});
function getStyle(el, styleProp) {
var currentDisplay = el.style.display,
val = null;
el.style.display = 'none';
if (el.currentStyle) {
val = el.currentStyle[styleProp];
} else if (window.getComputedStyle) {
val = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
}
el.style.display = currentDisplay;
return val;
}
console.log(getStyle(document.querySelector('div'), 'left')); // 10%
var mq = window.matchMedia('screen and (min-width: 900px)');
mq.addListener(foo);
function foo(mq) {
if (mq.matches) {
// вьюпорт больше 900px
} else {
// вьюпорт меньше 900px
}
}
foo(mq);
$(".next").click(function() {
current_fs = $(this).parent();
var hasEmpty = $('input', current_fs).css('border-color', '#ccc').filter(function() {
return $.trim($(this).val()) === '';
}).css('border-color', '#f00').length;
if (hasEmpty) {
alert('А заполнять поля за тебя Пушкин будет?');
return false;
}
// Остальной код обработчика
});
Проверку по каждому отдельному полю, с учетом необходимых требований (формат Email, кол-во символов и т.д.) - это уже сами. div {
height: 100vh;
}
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver,
config = {
attributes: true,
attributeFilter: ['style']
},
target = document.getElementById('my_id');
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
console.log(mutation.target.style.display);
});
});
observer.observe(target, config);
;(function($){
$.fn.fadeInDelay = function(){
var init = function(){
$(this).hide().delay($(this).data('delay')).fadeIn();
};
return this.each(init);
};
}(jQuery));
$('div').fadeInDelay();