set attribute javascript
var element = document.getElementById("elemId");
element.setAttribute("attributeName", "value");element.setAttribute(<name>, <value>);
// ex
var aElement = document.querySelector("a");
aElement.setAttribute("href", "https://isitchristmas.com/");
// same as <a href="https://isitchristmas.com/"></a>Element.setAttribute(name, value);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;');document.getElementsByTagName("H1")[0].setAttribute("class", "democlass");
Also in JavaScript:
- How to add a property at the middle of an object in javascript
- how to make modules structure like lodash
- discord.js custom create channel
- onfocus jquery
- js window resize listener
- calculate two number and diplay next field without reload the page javascript
- discord.js role permissions
- TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined at validateString (internal/validators.js:120:11)
- jquery remove style
- forjs check if key in json
- jhow to make a fish in javascript
- node red reverse proxy for ui to root
- access to model from js
- webpack react proxy not working
- javascript can you defer inline
- angular download blob pdf
- how to remove last index of array in javascript
- event handler attachment jquery
- toLocalString
- javascript remove first space in string
- add all elements in array javascript
- async await arrow function
- datatable on error.dt
- javascript run something after x seconds