out of curiosity is there a way to access this.color
from the paint
function?
function Foo(color)
{
this.color = color;
this.paint = function paint()
{
$("select").each(function(idx, el)
{
$(el).css("background", color); // OK
// $(el).css("background", this.color); // this.color is undefined
})
}
}
new Foo("red").paint();
Thanks
var that = this;
function (idx, el) {
// access what used to be this.color as that.color
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With