Is it possible to get an attribute of a DOM element, for example line-height, using javascript? I need to get this value to be able to add it with another value. I want this to be dynamic, that if I change this value in css, it will automatically change in javascript
-
w3schools.com/js/js_htmldom_css.asp check this link :)Jule Wolf– Jule Wolf2020-11-26 12:23:09 +00:00Commented Nov 26, 2020 at 12:23
-
2This is to pass a value to the attribute, I want to get the value of the attributeGobsRuiz– GobsRuiz2020-11-26 12:36:08 +00:00Commented Nov 26, 2020 at 12:36
Add a comment
|
1 Answer
You can use getComputedStyle()
var element = document.getElementById('id_of_element')
var elementStyle = window.getComputedStyle(element);
var lineh = elementStyle.getPropertyValue('line-height')
1 Comment
GobsRuiz
Thank you very much friend! It is difficult to ask questions here. There is always someone who doesn't know and demoting the question. Thank you very much for your attention, this information will help me a lot