Katy93,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
div{
width: 100px;
height: 100px;
border: 1px dashed Gray;
padding: 5px;
}
.Red{
background-color: Red;
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.getElementById("text").style.backgroundColor = "LightGrey";
var LightGrey = document.getElementById("text").style.backgroundColor;
document.addEventListener('click',
function(event) {
if(event.target.style.backgroundColor == LightGrey) alert("LightGrey");
})
});
</script>
</head>
<body>
<div id="text">click me</div>
<div class="Red"></div>
</body>
</html>