views:

54

answers:

1

I'm trying to write a very simple plugin that on anchor mouseover increases the respective anchor text size and on mouseout removes the anchor. The problem is that I can't get the right "this". so i have:

    (function($){
 $.fn.extend({
  //function name
  textOverlay : function(){
  //return
  return this.each(function(){
   var cucu = $(this);
   $(this).hover(
    function(){
     cucu.css({'font-size':'20px'});
    },
    function(){
     cucu.remove();
    }
   );
  }); 
  }
 });
})(jQuery);

and I call it like this:

    $(document).ready(function(){
 $('a').thiseOverlay();
});

I guess I should use something like .call() or .apply(), but I'm not sure how, I couldn't find good resources.

+4  A: 

It should work if you simply call $('a').textOverlay() instead of $('a').thiseOverlay() what you did.

Gumbo
i miss-typed when i wrote the code, but just in here cause i tried to simplify the code and i forgot to modify that. so in my real code i called it right : $('a').textOverlay(), and it doesn't work.
kmunky
pfiu...now it works, but i don't know what was the problem. maybe i forgot to refresh the page :D thanks, sorry for this dumb question :)
kmunky