Jquery İndex Eq
İndex:
Bu seçili nesnenin indeksini verir.
Küçük örnek bir slider uygulaması yapalım .
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta
http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<script
type="text/javascript"
src="http://code.jquery.com/jquery-1.7.2.min.js" ></script>
<script>
$(function(){
$(".tab").hide();
$(".tab:not(:first)").show();
$("ul
li").click(function(){
var
a= $(this).index();
$(".tab").hide();
$(".tab:eq("+a+")").show(1000);
});
});
</script>
<style>
ul li{
list-style:none;
float:left;
padding-left:50px;
}
</style></head><body>
<div
class="tab"><img
src="../971858_10151620033272398_121393181_n.jpg" />
</div>
<div
class="tab"><img src="../1.png" /></div>
<div
class="tab"><img src="../bg.jpg" /></div>
<ul> <li><a
href="#" > 1.tab</a></li><li><a
href="#" > 2.tab</a></li><li><a href="#"
> 3.tab</a></li><li><a href="#" >
4.tab</a></li>
</ul>
</body></html>
Yorumlar
Yorum Gönder