I have a list of dynamically generated divs and I have this script in order to make alternating background colors – for IE’s sake.
<style type="text/css">
.box { height:30px; width:100px; background-color:#fff; }
</style>
<script type="text/javascript">
$(document).ready(function () {
$(".box:odd").css("background-color", "#f1f1f1");
});
</script>
My html:
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
...
I would like to apply a special css style to the :last-child, but only if the :last-child is not :odd – meaning only if it has a white background.
How do I do that?
You can try this:
here is the fiddle:
http://jsfiddle.net/jYxeA/