Pietro Vieira (Tecnologia e informação)

Archive for the ‘JavaScript’ Category

Publicado por: pietrobr em: Maio 29, 2008

SlideUP em JQuery
Source: jquery-latest
<html>
<head>
  <script src=”jquery-latest.js“></script>
 
  <script>
  $(document).ready(function(){
   
    $(document.body).click(function () {
      if ($(“div:first”).is(“:hidden”)) {
        $(“div”).show(“slow”);
      } else {
        $(“div”).slideUp();
      }
    });
  });
  </script>
  <style>
  div { background:#3d9a44; margin:3px; width:80px;
        height:40px; float:left; }
  </style>
</head>
<body>
  Click me!
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</body>
</html>

Codigo:
<!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″ />
<title>Untitled Document</title>
<style>
 #resultado{ border:1px solid #3366CC;}
</style>
<script type=”text/javascript”>
 function propriedadesImagem(id)
 {
  var idDiv = document.getElementById(id);
  var rsDiv = document.getElementById(‘resultado’);
  foto = new Image();
  foto.src = idDiv.src;
  rsDiv.innerHTML = “Width: “+foto.width+” Height: “+foto.height+”Caminho da foto: “+foto.src;
 }
</script>
</head>
<body>
<a href=”javascript:void(0)” onclick=”propriedadesImagem(‘foto’)”>Ver Informações</a><br />
<img id=”foto” src=”imagem.jpg” /><br />
<div id=”resultado”></div>
</body>
</html>