$(function() { $('[id="red"]').css('background-color', 'red'); $('[id="green"]').css('background-color', 'green'); });
<div id="red">1</div> <div id="green">2</div> <div id="red">3</div> <div id="green">4</div> <div id="red">5</div> <div id="green">6</div>