add some scripts

This commit is contained in:
Alexander Popov 2022-03-26 03:37:19 +03:00
parent df28627c68
commit 1c051fe813
Signed by: iiiypuk
GPG Key ID: 3F76816AEE08F908
4 changed files with 14 additions and 0 deletions

View File

@ -5,6 +5,9 @@
- [Spread syntax](spread.js) - распаковка массива в аргументы
- [fetch](fetch.js) - ...
- [location.href](location.href.js) - Переход на другую страницу
- [Text Content](textContent.js) - Получить текстовое содержимое элемента
- [Add DOM Elements](addElements.js) - Добавление элементов в DOM
- [Add Class](addClass.js) - Добавление/Удаление классов
## Other
- [Webpack](webpack.md) example config

5
JavaScript/addClass.js Normal file
View File

@ -0,0 +1,5 @@
// Use element.classList.add to add a class:
element.classList.add('my-class');
// And element.classList.remove to remove a class:
element.classList.remove('my-class');

View File

@ -0,0 +1,3 @@
let newDiv = document.createElement('div');
newDiv.appendChild(document.createTextNode('some text'));
document.body.appendChild(newDiv);

View File

@ -0,0 +1,3 @@
document.getElementById('element').textContent;
// If you need to target < IE9 then you need to use
document.getElementById('element').innerText;