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.warn($.Color(this.style.backgroundColor).toHexString(false));
if ($.Color(this.style.backgroundColor).toHexString(false).match(/^#FF4500$/i)) {
this.style.transition = 'linear 2s';
this.style.backgroundColor = '#FFFFFF';
}
});
});