Ver Mensaje Individual
  #2 (permalink)  
Antiguo 25/02/2012, 02:51
Avatar de MarioAraque
MarioAraque
Colaborador
 
Fecha de Ingreso: octubre-2009
Ubicación: Valencia
Mensajes: 1.398
Antigüedad: 14 años, 6 meses
Puntos: 265
Respuesta: Como acceder objeto padre jquery?

Proba con esto

Código Javascript:
Ver original
  1. $(function(){
  2.         $( ".btnSwitch" ).click(function(){
  3.                         var boton = $(this);
  4.             boton.attr("src", "img/ajax-loader-mini.gif");
  5.             $.ajax({
  6.               url: "admin_ajax.php",
  7.               data: "switch=1&id="+$(this).attr("regid")+"&tabla=<?=$tabla?>&campo=visible&campoId=id",
  8.               cache: false,
  9.               success: function(msg){
  10.                 console.log(boton.attr("class")); //O cualquier otro atributo
  11.                 if(msg=='OK'){
  12.                     if($(this).attr("estado") == 1){
  13.                         $(this).attr("src", "img/offline.png");
  14.                         $(this).attr("estado", 0);
  15.                     }else{
  16.                         $(this).attr("src", "img/online.png");
  17.                         $(this).attr("estado", 1);
  18.                     }
  19.                 }
  20.               }
  21.             });
  22.         });
  23.     });

Eso del atributo "estado" lo agregas vos? o "estado" es una clase? Mas alla de eso, los $(this) deberias cambiarlos por la variable "boton" que declaras mas arriba.

Saludos.