update README for JavaScript
This commit is contained in:
5
code/JavaScript/DOM/addClass.js
Normal file
5
code/JavaScript/DOM/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
code/JavaScript/DOM/addElements.js
Normal file
3
code/JavaScript/DOM/addElements.js
Normal file
@@ -0,0 +1,3 @@
|
||||
let newDiv = document.createElement('div');
|
||||
newDiv.appendChild(document.createTextNode('some text'));
|
||||
document.body.appendChild(newDiv);
|
||||
3
code/JavaScript/DOM/addEventListenter.js
Normal file
3
code/JavaScript/DOM/addEventListenter.js
Normal file
@@ -0,0 +1,3 @@
|
||||
const button = document.getElementById('button');
|
||||
|
||||
button.addEventListener("click", function() { console.log('click'); })
|
||||
4
code/JavaScript/DOM/attributes.js
Normal file
4
code/JavaScript/DOM/attributes.js
Normal file
@@ -0,0 +1,4 @@
|
||||
elem.hasAttribute(name) // проверяет наличие атрибута.
|
||||
elem.getAttribute(name) // получает значение атрибута.
|
||||
elem.setAttribute(name, value) // устанавливает значение атрибута.
|
||||
elem.removeAttribute(name) // удаляет атрибут.
|
||||
Reference in New Issue
Block a user