How to compare color assigned for an element using JavaScript

前端 未结 2 1675
挽巷
挽巷 2021-01-27 13:37

In JavaScript using jQuery, how does one test whether the color assigned to an element is red blue, having an id as \'ID\'.

The JavaScript stat

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-27 13:51

    I also would suggest using classes, but if you really want to know the color of something I would use a javascript library to parse the return from .css, like this one: http://www.phpied.com/rgb-color-parser-in-javascript/

    Here is an example of it in use: http://jsfiddle.net/keegan3d/5SBpk/

提交回复
热议问题