add some scripts
This commit is contained in:
parent
df28627c68
commit
1c051fe813
@ -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
5
JavaScript/addClass.js
Normal 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');
|
3
JavaScript/addElements.js
Normal file
3
JavaScript/addElements.js
Normal file
@ -0,0 +1,3 @@
|
||||
let newDiv = document.createElement('div');
|
||||
newDiv.appendChild(document.createTextNode('some text'));
|
||||
document.body.appendChild(newDiv);
|
3
JavaScript/textContent.js
Normal file
3
JavaScript/textContent.js
Normal file
@ -0,0 +1,3 @@
|
||||
document.getElementById('element').textContent;
|
||||
// If you need to target < IE9 then you need to use
|
||||
document.getElementById('element').innerText;
|
Loading…
Reference in New Issue
Block a user