JavaScript
14
Вклад в тег
найти все слова начинающиеся на t,
let matchWords = document.querySelector('p').textContent.replace(/[\.,:;-]/g, '').split(' ').filter(e => e.toLowerCase()[0] == 't').join(', ')
console.log(matchWords)
var testResult
function ajax () {
return new Promise(resolve => {
$.ajax({
url: 'test.php',
method: "POST",
data: { test: 'test', },
success: data => resolve(data)
})
})
}
(async () => {
testResult = await ajax ()
console.log(testResult)
})()
let block = document.querySelectorAll('.block');
let container = document.querySelector('.container');
for(let el of block){
el.addEventListener('click',()=> {
container.setAttribute('class',`${container.classList[0]} ${el.classList[1]}`);
});
}
<div class="container"></div>
<div class="blocks">
<div class="block _black"></div>
<div class="block _blue"></div>
<div class="block _red"></div>
<div class="block _yellow"></div>
</div>
let container = document.querySelector('.container');
document.querySelector('.blocks').addEventListener('click',e => {
if(e.target.classList.contains('block')) container.className = `${container.classList[0]} ${e.target.classList[1]}`;
});