tags:

views:

223

answers:

2

i have this javascript code to which i want to add the jquery fade-in effect

hover.addEventListener('mouseover',function () {Core.addClass(cpanel,"on");},false);

Core is another library i am using. the above event listener just enables the cpanel div to visible state. how do i make it fade into the view. i am using jquery-ui and am very new at it.

thanks a lot in advance.

+1  A: 

Assuming your cpanel div has a class of 'on', you could do this:

$('.on').fadeIn("slow"); //.fadeIn("normal"); or .fadeIn("fast");

See jQuery's fadeIn effect

karim79
i have a doubt. in the above snippet you havent mentioned cpanel which is the div i want to display?
amit
@amit - give your cpanel div an ID like id="cpanel" and set the style to style="display:none" and then do $('#cpanel').fadeIn("slow");
karim79
thanks a lot @karim. it works. now how do i remove the div from displaying on mouseout? i was using this: hover.addEventListener('mouseout', function () {Core.removeClass(cpanel,"on");},false);
amit
i tried using .fadeOut. it fades the cpanel. but it reappears/fades/reappers....i mean to say it continues to fade-out-fade-in forever.
amit
@amit - sounds like it's conflicting with that other script. Try disabling that and see what happens.
karim79
A: 

You can use fadeIn:

http://docs.jquery.com/Effects/fadeIn#speedcallback

If you still want to use your snippet to add that class (which can also be done in jQuery btw), just put the jQuery fadein code before it. This will cause the fadeIn effect to happen, and then just add the (probably redundant) "on" class.

In response to comment: This is the code I would try first

hover.addEventListener('mouseover',function () {
  cpanel.fadeIn("slow"); // this is if cpanel is a jQuery object.  If it is an element, do $(cpanel).fadeIn("slow");
  Core.addClass(cpanel,"on");
}, false);

If that still doesn't work, can you let me know what is happening, if anything? Thanks.

Sean Nyman
i tried doing this. didnt work.
amit