I need to get the last applied CSS rule for the width
attribute on an HTML element using Javascript.
Example 1:
<input type="text" class="fullwidth"/>
input {
width: 300px;
}
.fullwidth {
width: 100%;
}
Example 2:
<input type="text" class="fullwidth halfwidth"/>
input {
width: 300px;
}
.fullwidth {
width: 100%;
}
.halfwidth {
width: 50%;
}
I need to get 100%
for the first case and 50%
for the second one. Basically I need the following highlighted value:
I can't use the getComputedStyle
method because it retrieves the computed width in pixels, but I need the same value in the CSS rule.
Is there a way to achieve it?
Thanks in advance