Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
一切都在我尝试过的问题中:$('#my-div').css('box-shadow');但它返回类似:rgb(25,65,588) 10px 10px 10px。如何只获得颜色?
$('#my-div').css('box-shadow');
rgb(25,65,588) 10px 10px 10px
这将得到 rgb 或 rgba 表达式
$('#my-div').css('box-shadow').replace(/^.*(rgba?\([^)]+\)).*$/,'$1')
然后您可以使用转换器获取十六进制值