Before asking for this code I tried to create the variable and use it. I did 
not optimize it because im noob for this and still I am learning, thanks for 
the help, nevertheless still it follows without working and I do not have idea 
because it does not do it

God bless google translator.

This code work

$(".toggle_cat a").each(function(i){
 $(this).attr("title", "Click here to exclude this cat");
 $(this).click(function(event){
  $(this).toggleClass("selected");
  var self = this; /* saves your 'this' for use in the toggle */
  $("." + this.rel).toggle(
    /*
      function() { $("." + self.rel).hide('slow'); },
      function() { $("." + self.rel).show('fast'); }
    */
  );
 });
});


This code dosnt work

$(".toggle_cat a").each(function(i){
 $(this).attr("title", "Click here to exclude this cat");
 $(this).click(function(event){
  $(this).toggleClass("selected");
  var self = this; /* saves your 'this' for use in the toggle */
  $("." + this.rel).toggle(
      function() { $("." + self.rel).hide('slow'); },
      function() { $("." + self.rel).show('fast'); }
  );
 });
});


----- Original Message -----
From: "Joel Birch" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, April 04, 2007 9:28 AM
Subject: [jQuery] Re: Problem with togle()



...and optimised further to reduce redundant jquery object creation
and property look-ups:

$(".toggle_cat a").each(function(){
$(this)
.attr("title", "Click here to exclude this cat")
.click(function(){
$(this).toggleClass("selected");
var rel = this.rel;
$("." + rel).toggle(
function() { $("." + rel).hide('slow'); },
function() { $("." + rel).show('fast'); }
);
});
});

Joel.

On 04/04/2007, at 10:21 PM, Joel Birch wrote:

>
> I guess that inside the anonymous functions within toggle, 'this'
> is no longer the 'this' that you intend it to be. Try setting a
> variable to the 'this' you want outside of the toggle instead -
> like so:
>
>  $(".toggle_cat a").each(function(i){
>   $(this).attr("title", "Click here to exclude this cat");
>   $(this).click(function(event){
>    $(this).toggleClass("selected");
>    var self = this; /* saves your 'this' for use in the toggle */
>    $("." + this.rel).toggle(
>        function() { $("." + self.rel).hide('slow'); },
>        function() { $("." + self.rel).show('fast'); }
>    );
>   });
>  });
>
> Joel.
>
>
> On 04/04/2007, at 10:16 PM, Sebastián V. Würtz wrote:
>
>>  $(".toggle_cat a").each(function(i){
>>   $(this).attr("title", "Click here to exclude this cat");
>>   $(this).click(function(event){
>>    $(this).toggleClass("selected");
>>    $("." + this.rel).toggle(
>>        function() { $("." + this.rel).hide('slow'); },
>>        function() { $("." + this.rel).show('fast'); }
>>    );
>>   });
>>  });
>
>


__________ NOD32 2167 (20070403) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com



--
Estoy usando la versión gratuita de SPAMfighter para usuarios privados.
Ha eliminado 23 correos spam hasta la fecha.
Los usuarios de pago no tienen este mensaje en sus correos.
Obtenga SPAMfighter gratis aquí: http://www.spamfighter.com/les

Reply via email to