SO20574006
javascript: search and replace hexadecimal color code with a different color code
by anaran
HTML
<div style="padding:5px;background:#FF4500;text-align:center;">Some Text Here</div><br>
JavaScript
$(document).ready(function() {
$('div').each(function () {
console.log(this.style.backgroundColor);
if (this.style.backgroundColor.match(/^rgb\(255, 69, 0\)$/)) {
this.style.transition = 'linear 2s';
this.style.backgroundColor = '#FFFFFF';
}
});
});