Its probably stupid noob general javascript question but ive been trying to find an answer for days.
Lets say i use jquery plugin that takes object as settings (i will show on flexbox called fluixbox) and i want it to take some of the settings from html.
html:
<a data-color="rgba(40,25,255,1)"> My colorful image </a>
javascript:
$("a").fluidbox({ overlayColor: $(this).data("color") })
I think its pretty self explenatory, i tried to do everything. I think problem must be something with scope. If i just create function that returns rgba(40,25,255,1) and put it instead $(this).data("color") then it does work.
Thank you for any response.
thiswithin the attribute is not referring toa, but defaults to the globalwindowobject. you need to assign the color to a variable, then use that variable as the value instead.