We would like to know how to compare element color with rgb function color.
<!-- www . ja v a2s . com-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-1.9.1.js'></script>
<style type='text/css'>
h1 {
color: red;
}
</style>
<script type='text/javascript'>
$(window).load(function(){
$(function () {
if ($('h1').css('color') == 'rgb(255, 0, 0)') {
$('h1').css('color', 'blue');
}
});
});
</script>
</head>
<body>
<h1>My color is Red</h1>
</body>
</html>
The code above is rendered as follows: