-1

Basically, I'm wondering if it's possible to have a line of javascript isolate a specific hex code on a page (lets say #1166e7) and change it to another hex code (lets say #ff0000).

I know that this is a weird question because the process could easily be done by just changing the css, but in my situation, just pretend I can't access the css.

Thanks in advance.

John R Perry
  • 3,916
  • 2
  • 38
  • 62
  • what you have tried? – Mritunjay Jan 16 '15 at 03:08
  • Don't quite understand your question. You are trying to find all the color with #1166e7 and change it with #ff0000. I know changing an element background color is by: document.getElementById('myElemID').style.backgroundColor = '#ff0000'; where myElemID is the ID of the element you want to change the background color. – webtrick101 Jan 16 '15 at 06:51
  • @Mritunjay I haven't tried anything yet :/ I don't actually know if javascript would be the way to go. I made an temp url for an example of what I'm trying to do http://goo.gl/SLlE52 – John R Perry Jan 16 '15 at 10:05

1 Answers1

0

You can go over all css properties of every element present on the page and replace the value you are looking for. You could do something like:

$("*").foreach(function() {
    for(var key in this.style) {
        if(this.style[key] == '#1166e7') {
            this.style[key] = '#ff0000';
        }
    }
});

Note that I used the jQuery Framework to select all elements within the page. See Javascript: How to loop through ALL DOM elements on a page? for better approaches with wich you can iterate over all elements.

Community
  • 1
  • 1
Guillermo
  • 764
  • 6
  • 15