Witam, mam nastepujacy skrypt:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" > <meta name="author" content="lukasz_os" > <script type="text/javascript" src="jquery-1.5.1.min.js"></script> <script type="text/javascript"> function rotate(){
last=$("#container .news").index($('.news:last')[0]);
ind=$("#container .news").index($('.news:visible')[0]);
$('.news').eq(ind).hide();
if(ind==last){
ind="0";
}
else
{
ind++;
}
$('.news').eq(ind).show();
}
$().ready(function(){
$('#container .news:first').show();
var inter = setInterval("rotate()",2000);
$(".tit").click(function() {
clearInterval(inter);
var href = $(this).attr("href");
$('.tit').css('background-color', 'white');
$(this).css('background-color', 'green');
$('.news').hide();
$(href).show();
return false;
});
});
* {
margin:0;
padding:0;
}
body {
background:#ffffff;
color:#000;
}
.news {
width:300px;
height:200px;
border:1px solid #000;
display:none;
}
#container {
margin:20px;
width:302px;
height:202px;
}
<div class="news" id="#n1" style="background-color:red;"> div 1ijiojiji
<div class="news" id="#n2" style="background-color:green;"> div 2joijioj
<div class="news" id="#n3" style="background-color:black;"> div 3iojioj
<div class="news" id="#n4" style="background-color:yellow;"> div 4iojioj
<a class="tit" href='#n1'>1
</a> <a class="tit" href='#n2'>2
</a> <a class="tit" href='#n3'>3
</a> <a class="tit" href='#n4'>4
</a>
Jednakze po kliknieciu przycisku div o id "href" sie nie wyswietla czy ktos wie czemu ?
Ten post edytował ir3nicus 21.04.2011, 14:32:10