I need a way in order to restrict users from using certain colors (for accessibility purposes). I have an array of colors:
var bannedColors = ['aqua', 'mediumseagreen', 'deepskyblue', 'mediumorchid', 'darkslategray', 'teal', 'mediumaquamarine', 'steelblue', 'indigo', 'slategrey', 'gold', 'darkorange', 'mediumvioletred', 'lightslategrey', 'orange', 'orangered', 'crimson', 'silver', 'black', 'yellowgreen', 'firebrick', 'mediumpurple', 'darkcyan', 'dodgerblue', 'greenyellow', 'brown', 'darkslateblue', 'lightseagreen', 'midnightblue'];
I tried doing something like:
if($.inArray($('.content').children().css('color'), bannedColors)) {
$('.content').children().css('color', '');
}
But it doesn't seem to work. I want/need it to see the color of a div and all of it's children. For example:
<div class="content">
<p style="color: aqua">Here is some text with color...</p>
<div class="inner-content">
<p style="color: mediumseagreen">Another set of text with another color...</p>
</div>
</div>
The two colors, which are in my list of banned colors, should be stripped and replaced with black. Any suggestions would be greatly appreciated.