11 Eylül 2013 Çarşamba

16.09.2013:



                                EACH() METODU


   For döngüsü olarak düşünün , tek  farkı ise each elementlerin toplamını kendi alıyor ve hepsini tek tek işliyor.


örnek:
 

 
 
 
<!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=iso-8859-1" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
    $("li").each(function(){
      alert($(this).text())
    });
  });
});
</script>
<title>each ödev</title>
</head>
<body>
<button>göster</button>
<ul>
<li>Coffee</li>
<li>Milk</li>
<li>Soda</li>
</ul>
</body>
</html>

Hiç yorum yok:

Yorum Gönder