Ver Mensaje Individual
  #7 (permalink)  
Antiguo 06/08/2010, 15:27
Dany_s
 
Fecha de Ingreso: diciembre-2009
Ubicación: Misiones
Mensajes: 867
Antigüedad: 14 años, 5 meses
Puntos: 65
Respuesta: acceder al mismo div desde diferentes links?

si los 2 clicks en los 2 elementos hacen lo mismo no hace falta repetir código, solo seleccionar los 2 elementos

Código Javascript:
Ver original
  1. $(function(){
  2.           $("#titulo_1, #foto_1").click(function(event) {
  3.           event.preventDefault();
  4.           $("#caixanew1").slideToggle();
  5.       });

ahora me imagino que para mostrar cada una de las noticias estarás repitiendo todo el mismo código, te conviene usar un contenedor para manejarte con los elemetos dentro de el cuando hacen click
algo como:

Código HTML:
Ver original
  1.   <script src="http://code.jquery.com/jquery-latest.js"></script>
  2.   <script>
  3. $(function(){
  4.  
  5.       $(".noticia img, .noticia a").click(function(event) {
  6.           $(this).closest('.noticia').find('p').slideToggle();
  7.           return false;
  8.       });
  9.  
  10. });
  11.   <style>
  12.     p{display:none}
  13.   </style>
  14. </head>
  15.  
  16.     <div class="noticia">
  17.         <img src="http://www.elmostrador.cl/media/2009/12/planeta-tierra-desde-el-espacio_50x50.jpg">
  18.         <a href="#">Título 1</a>
  19.         <p>1 Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
  20.     </div>
  21.  
  22.     <div class="noticia">
  23.         <img src="http://www.elmostrador.cl/media/2009/12/planeta-tierra-desde-el-espacio_50x50.jpg">
  24.         <a href="#">Título 2</a>
  25.         <p>2 Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
  26.     </div>
  27.  
  28.     <div class="noticia">
  29.         <img src="http://www.elmostrador.cl/media/2009/12/planeta-tierra-desde-el-espacio_50x50.jpg">
  30.         <a href="#">Título 3</a>
  31.         <p>3 Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
  32.     </div>
  33.  
  34.     <div class="noticia">
  35.         <img src="http://www.elmostrador.cl/media/2009/12/planeta-tierra-desde-el-espacio_50x50.jpg">
  36.         <a href="#">Título 4</a>
  37.         <p>4 Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
  38.     </div>
  39.  
  40.     <div class="noticia">
  41.         <img src="http://www.elmostrador.cl/media/2009/12/planeta-tierra-desde-el-espacio_50x50.jpg">
  42.         <a href="#">Título 5</a>
  43.         <p>5 Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
  44.     </div>
  45.  
  46. </body>
  47. </html>

o sea, cuando hacen click en el link o la imagen subo hasta el contenedor con class noticias y desde ahi busco el párrafo

Última edición por Dany_s; 06/08/2010 a las 15:34