I want to make a function that change css property of an object. I tried code below
function setBgColor($obj, $color) {
$obj.css("background-color", $color);
}
setBgColor($(".bg-red"), "red");
and it works. but I would like to to make the function to be called from an object like this
function setBgColor($color) {
$(this).css("background-color", $color);
}
$(".bg-red").setBgColor("red");
Can someone help?