0
Is there any way to do this? I’m repeating a lot of code with the setAttribute
in a single element, so I’m researching if there’s any way to do this in a more organized and optimized way, but I haven’t found it yet.
Below is an EXAMPLE of what I’m doing and an EXAMPLE of what I wanted to do if possible:
Any link I will use in the example:
<a class="teste"></a>
JS code I am doing to set the attributes:
document.querySelector('.teste').setAttribute('href', 'https://www.teste.com')
document.querySelector('.teste').setAttribute('title', 'Site de Teste')
document.querySelector('.teste').setAttribute('id', 'idteste')
How I wanted if possible or something similar:
document.querySelector('.teste').setAttribute(['href', 'title', 'id'], ['https://www.teste.com', 'Site de Teste', 'idteste'])
Would have something similar to that already native to Javascript?
Natively has not.
– Isac