hover de imagens toggle src

No Comments »
  1.  
  2. <html>
  3. <head>
  4. <script type="text/javascript">
  5. window.onload = function()
  6. {
  7.         var normal = ;
  8.         toggle_src( id(‘a1′) );
  9.         toggle_src( id(‘a2′) );
  10. }
  11. function id( el ){
  12.         return document.getElementById( el );
  13. }
  14. function toggle_src( el )
  15. {
  16.         el.onmouseover = function(){
  17.                 normal = this.src;
  18.                 this.src = this.lowsrc;
  19.         }
  20.         el.onmouseout = function(){
  21.                 this.src = normal;              
  22.         }
  23. }
  24. </script>
  25. </head>
  26. <body>
  27.         <a href="home.html"><img src="normal-home.jpg" width="75" id="a1" height="58" alt="Botão para a Página Inicial" lowsrc="hover-home.jpg" /></a>
  28.         <a href="contato.html"><img src="normal-contato.jpg" width="75" id="a2" height="58" alt="Botão para a Página Inicial" lowsrc="hover-contato.jpg" /></a>
  29. </body>
  30. </html>
  31.  
julho 14th 2010 Não Classificados

onkeyup com delay..

No Comments »
  1.  
  2. <html>
  3. <head>
  4. <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
  5. <script type="text/javascript">
  6. $(document).ready(function(){
  7.         var intervalo = 0;
  8.         $("input[name='search']").keyup(function(){
  9.  
  10.                 clearInterval( intervalo );//ou clearTimeout()
  11.                 intervalo = window.setTimeout( ajax, 1500 );
  12.         });
  13. });
  14. function ajax()
  15. {
  16.         alert( ‘Agora pode ir executar’ );
  17. }
  18. </script>
  19. </head>
  20. <body>
  21.         <form action="" method="post">
  22.                 <fieldset>
  23.                         <label><input type="text" name="search" /></label>
  24.                 </fieldset>
  25.         </form>
  26. </body>
  27. </html>
  28.  
julho 14th 2010 Não Classificados

Label de Option da tag select

No Comments »
  1.  
  2. <html>
  3. <head>
  4. <script type="text/javascript">
  5. function label_option( el )
  6. {
  7.         var label = el.options[ el.selectedIndex ].text;
  8.         alert( label );
  9. }
  10. window.onload = function()
  11. {
  12.         document.getElementById( ‘teste’ ).onchange = function()
  13.         {
  14.                 label_option( this );
  15.         }
  16. }
  17. </script>
  18. </head>
  19. <body>
  20.         <form action="" method="post">
  21.         <label>Teste: <select name="teste" id="teste">
  22.                         <option value="">–</option>
  23.                         <option value="1">Um</option>
  24.                         <option value="2">Dois</option>
  25.                         <option value="3">Tres</option>
  26.                 </select></label>
  27.         </form>
  28. </body>
  29. </html>
  30.  

referência:
http://www.mredkj.co…utorial002.html

julho 14th 2010 Não Classificados