Slice start till ends : slice « jQuery « JavaScript DHTML






Slice start till ends

     
<html>
  <head>
    <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
           function colorEm() {
              var $div = $("div");
              $div.css("background", "red");
              $div.slice(2).css("background", "yellow");   
           }
           $("button").click(colorEm);
        });
    </script>
    <style>
      div { width:40px; height:40px; margin:10px; float:left;}
    </style>
  </head>
  <body>
    <body>
      <button>Click the button</button>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
  </body>
</html>

   
    
    
    
    
  








Related examples in the same category

1.Slice start and end
2.Slices paragraphs to include only the first and second element.
3.Slices paragraphs to include only the second element.
4.Slice paragraphs to include only the second and third element.
5.Slice li under a ul
6.slice to the end