+ 2
Hello, how can I access the attributes of an element by using Javascript? I tried this without success. Thanks.
5 Respuestas
+ 4
It should be like this:
https://code.sololearn.com/W5xLY00Jn7g5/?ref=app
+ 5
Although @Jonathan's way is the preferred method in pure Javascript (IMO) you could also just shorten it to;
getComputedStyle(box).width
+ 4
Or you can use jquery.
import it first, then
$("#id").attr("atrribute")....
+ 4
The HTMLElement.style property is used to get as well as set the inline style of an element. It can't read external CSS style.
More info pls check
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
+ 3
Thanks you all. I used Jonathan's solution.