How to get hex color value rather than RGB value?

前端 未结 19 3212
猫巷女王i
猫巷女王i 2020-11-21 23:06

Using the following jQuery will get the RGB value of an element\'s background color:

$(\'#selector\').css(\'backgroundColor\');

Is there a

19条回答
  •  面向向阳花
    2020-11-21 23:33

    My beautiful non-standard solution

    HTML

    jQuery

    $("#selector").attr("style").replace("background-color:", "");
    

    Result

    #f5b405
    

提交回复
热议问题