<!DOCTYPE HTML>
<html>
<head>
<style>
.block {
width:200px;
height:200px;
}
.red {
background-color:red;
}
.green {
background-color:green;
}
</style>
</head>
<body>
<div class="block red" media="print"></div>
<script>
var elem = document.querySelectorAll("[media=print]");
elem[0].className = "block green";
</script>
</body>
</html>