setAttribute()
Element.setAttribute(name, value);element.setAttribute(name, value);
var d = document.getElementById("d1");
d.setAttribute("align", "center");const link = document.querySelector('a');
console.log(link.getAttribute('href'));
link.setAttribute('href', 'https://yandex.ru');
link.innerText = 'The Next Link';
const mssg = document.querySelector('p');
console.log(mssg.getAttribute('class'));
mssg.setAttribute('class', 'success');
mssg.setAttribute('style', 'color: green;');
Also in JavaScript:
- js root url
- store current date in chrome storage extension
- bash expression
- js reverse number
- react html symbol code
- detect a click outside an element javascript
- how to flatten array with reduce in javascript
- recorrer letra por letra js
- js no new line console.log
- c# print object to json
- javascript dictionary
- functional component react with state
- js change key value in object
- javascript loop through class elements
- user property in express jwt
- javascript set query parameter
- react this.state.selectedDays.toLocaleDateString is not a function
- jest
- fullscreen electron
- disable text selection in js
- store data in array jquery
- angular limit string length
- es6 method definition syntax
- javascript picture delete after time