I want to get all the styles which has been set dynamically (which applies as inline-styles) on an element.
For example
<span class="text" style="color: rgb(128, 128, 255); font-size: 24px;">Name</span>
I want to get the value of style attribute in a JS variable and save it. I have tried using jQuery's .attr('style'), but it's giving undefined
Also, As suggested here How to get inline CSS style property from element to use
getComputedStyle
but to get styles I need to mention all the styles like
var el = document.querySelector("selector")
console.log(el.style.SomeStyle);
but there are various styles which a user can set dynamically. So, do I need to mention all the inline-styles individually or is there some better way to get that?
Thanks in advance for any help
Update from the void's comment:
As described here Can jQuery get all CSS styles associated with an element?
marknadal had wrote a function that retrieves both inline and external styles, but I just need the inline-styles irrespective of all css classes attached