<select id="select"></select>
const select = document.querySelector('#select');
for (let i = 1; i <= 100; i++) {
const option = document.createElement('option');
option.textContent = option.value = i;
select.append(option);
}
const div = document.querySelectorAll('div');
const colors = [ 'red','blue','yellow','green' ];
div.forEach((el, index) => {
el.style.width = '200px';
el.style.height = '50px';
el.style.border = '1px solid gray'
el.style.backgroundColor = colors[index];
});
$('#rooms label:last-child').on('click', function() {
$('#rooms label:not(:last-child)').css('background', 'green');
});
<form>
<input type="text" id="input">
</form>
<p id="demo"></p>
input.addEventListener('input', function () {
if (this.value.length > 140) {
demo.textContent = 'Ваш текст';
} else {
demo.textContent = '';
}
});
$('#input').on('input', function() {
if ($(this).val().length > 140) {
$('#demo').text('Ваш текст');
} else {
$('#demo').text('');
}
});
npm install
устанавливает оба dependencies и devDependenciesnpm install --production
устанавливает только dependenciesnpm install --dev
устанавливает только devDependencies const $navLink = $('.nav__link');
const activeClass = 'active';
const navClass = localStorage.getItem('add-class');
if (navClass) {
$navLink
.removeClass(activeClass)
.eq(navClass)
.addClass(activeClass);
}
$navLink.on('click', function() {
$navLink.removeClass(activeClass);
$(this).addClass(activeClass);
localStorage.setItem('add-class', $(this).index());
});
document.querySelectorAll('h2').forEach(h => {
if (h.innerText === 'тест') {
h.style.display = 'none';
}
});