help needed with javascript and "this" object | SoloLearn: Learn to code for FREE!


help needed with javascript and "this" object

The result i would like to get is explained in this code (js pannel). An element's onclick is listenend, and i would like to catch a style property of this element and copy it to another. Can you tell me how i can do this ? Thank you : )

6/11/2019 1:09:00 PM


7 Answers

New Answer


You can only read inline css by To read external css, use getComputedStyle(element).


ᐺ ! ᖇ ᖶ ᒪ Calviղ's solution works fine, but i'm interested by your solution if it's a different one. Understanding what happens with all these ways to create functions with JS is not very intuitive when coming from python 😂 I "tried to try" 😅 what you suggest, but did not see a difference. Could you be more precise how to do it ?


Yes, perfect 😃👌 Thank you so much Calviղ ! My problem is solved.


ᐺ ! ᖇ ᖶ ᒪ😊 Got it, thanks


Cépagrave it doesn't have a difference visually but I think it's more logical to attach a function to event instead of using `this`


Arrow functions don't have bind to `this`. Try using addEventListener with event target