JavaScript Tutorial/jQuery/ready

Материал из Web эксперт
Версия от 11:25, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Add ready function to document ready function

   <source lang="javascript">

<html>

 <head>
   <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
   <script type="text/javascript">

var tmpExample = {

 ready : function() {
   $("ul#tmpPlaces li.myStyle").siblings().addClass("tmpSiblings");
 }

}; $(document).ready(tmpExample.ready);

   </script>
   <style type="text/css">

h4 {

   font-size: 16px;
   margin: 0 0 5px 0;

} ul#tmpPlaces {

   list-style: none;
   margin: 0;
   padding: 0;

} ul#tmpPlaces li {

   margin: 1px;
   padding: 3px;

} li.tmpSiblings{

   background: khaki;

}

   </style>
 </head>
 <body>
  • a
  • b
  • c
  • d
  • e
  • f
  • g
 </body>

</html></source>


Document ready event

   <source lang="javascript">

<html>

 <head>
   <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
   <script type="text/javascript">
$(document).ready(function(){
    alert("Hi");
});
   </script>
 </head>
 <body>
   <a href="http://jquery.ru/">jQuery</a>
 </body>

</html></source>