const array = document.querySelectorAll('[class*="toggle-"]') // Взято из варианта @0xD34F
Array.from(array).forEach(el => {
const name = el.className.split('toggle-').join('')
el.classList.remove(el.className)
el.classList.add(name)
})
let key = 0;
document.getElementsByTagName('button')[0].addEventListener('click', () => {
if (key == 13)
console.log('Клава')
else
console.log('Мышка')
key = 0
})
document.addEventListener('keypress', (e) => {
key = e.keyCode
console.log(key)
})
const music = document.getElementById('music');
music.volume = 0.1
music.addEventListener('click', () => {
music.classList.toggle('active')
if (music.className.indexOf('active') === -1)
music.pause()
else
music.play()
})
const el = document.getElementById('yourElement')
el.addEventListener('animationend', function() {
el.classList.remove('animated fadeInDown')
})
plugins: [
new CopyWebpackPlugin([{
from: './src/fonts',
to: './fonts'
},
{
from: './src/favicon',
to: './favicon'
},
{
from: './src/img',
to: './img'
},
{
from: './src/uploads',
to: './uploads'
}
]),
]
const elements = document.getElementsByClassName('test')
for (let i = 0; i < elements.length; i++) {
elements[i].addEventListener('click', () => {
alert(i + ' элемент')
})
}
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: 'dev/client'
},
notify: false
});
});
gulp.task('watch', ['browser-sync',], function() {
gulp.watch('ваш_путь/**/*.js', browserSync.reload);
});
const block = document.querySelector('.benefits-block')
const childrenArray = block.children
block.addEventListener('mouseenter', function() {
for (let i = 0; i < childrenArray.length; i++) {
childrenArray[i].classList.add('enabled')
}
})
npm i -D babel-plugin-transform-react-jsx
gulp.task('babel', function() {
return gulp.src('js/source/**/*.js')
.pipe(babel({
plugins: ['transform-react-jsx']
}))
.pipe(gulp.dest('js/build'))
});