0

Is there a javascript/jQuery function that would Redefine the standard css color names? (Something you could simply copy/past into your projects.)

example:

<div id="example"></div>

<style>

#example { background: red; }

</style>

<script>

if(true) {
    function redefineColor () {
    var backgroundColor = $("*").css("background");   //select all elements

    if( backgroundColor == "#FF0000" ) {              //red color.
      $(this).css("background","#DC143C");              //other shade of red.
    } else { return false}
    redefineColor();
}
</script>

greetings

Kenneth
  • 13
  • 1
  • 6
  • 2
    No there is not, and the browser generally doesn't return hex, but rgb(a) for colors, which makes it hard to work with in javascript – adeneo Mar 02 '15 at 21:56
  • 1
    That sounds like a really bad idea. – Steve Wellens Mar 02 '15 at 21:58
  • A more straightforward solution: create a JS object with your desired names as keys and the appropriate hex/rgba as values. – Blazemonger Mar 02 '15 at 21:58
  • http://stackoverflow.com/users/901048/blazemonger, that sound good. Any idea where i could find some more info about this. – Kenneth Mar 02 '15 at 22:01
  • Big flaw in your `get all elements` concept. A value getter can only return one value, and that will be the first matching element of the selector – charlietfl Mar 02 '15 at 22:01
  • http://stackoverflow.com/users/1175966/charlietfl So, that would mean that the function would have to repeat itself. To find the next matching element, after the next, etc – Kenneth Mar 02 '15 at 22:03
  • @Blazemonger <- that's how you ping by the way ............. – adeneo Mar 02 '15 at 22:04
  • @adeneo, im getting there :) – Kenneth Mar 02 '15 at 22:05

0 Answers0