update README for JavaScript

This commit is contained in:
2024-04-28 00:18:39 +03:00
parent 3581b1f8a3
commit 3c5f55f5f6
13 changed files with 24 additions and 5 deletions

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 @@
const button = document.getElementById('button');
button.addEventListener("click", function() { console.log('click'); })

View File

@@ -0,0 +1,4 @@
elem.hasAttribute(name) // проверяет наличие атрибута.
elem.getAttribute(name) // получает значение атрибута.
elem.setAttribute(name, value) // устанавливает значение атрибута.
elem.removeAttribute(name) // удаляет атрибут.