Сообщение от Aetae
|
рони, да никуда не денутся, выбраны же по классу, а не по тегу.)
|
верно.
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
body{
background-color: #D2691E;
}
div{
border: #000000 1px solid
}
.cusshortstorynotfixed{
background-color: #006400;
height: 25px;
}
.clr{
background-color: #E0FFFF;
height: 5px;
}
.shortstorynotfixed{
background-color: #FFFF00;
height: 25px;
}
</style>
<script>
window.onload = function () {
var newsgl = document.getElementsByClassName('cusshortstorynotfixed'),
len = newsgl.length,
i = 1,
clr = document.createElement('div');
clr.className = 'clr';
while (i < len) {
var el = newsgl[i];
el && el.parentNode.insertBefore(clr.cloneNode(true), el.nextSibling);
i += 2;
};
newsgl = document.getElementsByClassName('shortstorynotfixed'), len = newsgl.length, i = 1;
while (i < len) {
var el = newsgl[i];
el && el.parentNode.insertBefore(clr.cloneNode(true), el.nextSibling);
i += 2;
}
};
</script>
</head>
<body>
<div class="cusshortstorynotfixed"></div>
<div class="cusshortstorynotfixed"></div>
<div class="cusshortstorynotfixed"></div>
<div class="cusshortstorynotfixed"></div>
<div class="cusshortstorynotfixed"></div>
<p></p>
<div class="shortstorynotfixed"></div>
<div class="shortstorynotfixed"></div>
<div class="shortstorynotfixed"></div>
<div class="shortstorynotfixed"></div>
<div class="shortstorynotfixed"></div>
</body>
</html>