Что не так делаю?
let uploadTo = null;
$('.file-upload-preview').click(function() {
uploadTo = this;
$('#file-upload').click();
});
$(".file-upload-preview")
на $(uploadTo)
. function simpleSlider(element) {
const root = typeof element === 'string'
? document.querySelector(element)
: element;
const items = root.querySelectorAll('.slider__item');
const prev = root.querySelector('.slider__btn-prev');
const next = root.querySelector('.slider__btn-next');
let index = 0;
function slideTo(newIndex) {
items[index].classList.remove('slider__item--active');
index = (newIndex + items.length) % items.length;
items[index].classList.add('slider__item--active');
}
prev.addEventListener('click', () => slideTo(index - 1));
next.addEventListener('click', () => slideTo(index + 1));
}
simpleSlider('#slider1');
simpleSlider(document.querySelector('#slider2'));
const blockSelector = '.block';
const buttonSelector = '[data-class]';
const activeClass = 'active';
const blocks = document.querySelectorAll(blockSelector);
const buttons = [...document.querySelectorAll(buttonSelector)];
const classes = buttons.map(n => n.dataset.class);
document.body.addEventListener('click', e => {
const button = e.target.closest(buttonSelector);
if (button) {
blocks.forEach(n => {
n.classList.remove(...classes);
n.classList.add(button.dataset.class);
});
buttons.forEach(n => n.classList.toggle(activeClass, n === button));
}
});
$(document).on('click', '[data-slide-to]', function() {
$(this).closest('.carousel').carousel(+this.dataset.slideTo);
});
str += symbolHash;
$('div').height(200).css({
border: '1px solid #000',
backgroundColor: 'green'
});
var blockContentTextHeight = blockPictHeight - (blockContentDescHeight + blockContentSubtextHeight)
$('.block-content-text').height( blockContentTextHeight );
var blockContentTextHeight = $('.block-content-text').height(blockPictHeight - (blockContentDescHeight + blockContentSubtextHeight) ).height();
console.log(typeof blockContentTextHeight);
height
со значением возвращается объект jQuery api.jquery.com/height/#height2 import './style.css';
const timeout = 5000,
content = document.querySelectorAll('div.main-content');
if (localStorage.getItem('mainContent') !== 'shown') {
setTimeout(() => {
content.forEach(i => i.classList.add('shown'));
localStorage.setItem('mainContent', 'shown');
}, timeout);
} else {
content.forEach(i => i.classList.add('shown'));
}
div.main-content {
display: none;
}
div.main-content.shown {
display: block;
}
<div class="main-content">1</div>
<div class="main-content">2</div>
<div class="main-content">3</div>