tags:

views:

46

answers:

1

Hi; In this code:

$(document).ready(function()
{
    $(".main_image .desc").show(); //Show Banner
    $(".main_image .block").animate({ opacity: 0.65 }, 1 ); 
    $(".image_thumb ul li:first").addClass('active');  
    $(".image_thumb ul li").click(function () 
    {
        var imgAlt = $(this).find('img').attr("alt");
        var imgTitle = $(this).find('a').attr("rel");
        var imgDesc = $(this).find('.block').html();
        var imgDescHeight = $(".main_image").find('.block').height();

        if ($(this).is(".active")) 
        {
        return false;
        } 
        else 
        {
            $(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250, 
            function() {
                $(".main_image .block").html(imgDesc).animate({ opacity: 0.85, marginBottom:"0" }, 250 );
                $(".main_image img").attr({ src: imgTitle , alt: imgAlt});
            });
        }
    });

i have changed click with mouse over, but how can i set mouseout event? Thanks in advance

+2  A: 

I don't see your mouseover event handler.

If you want a mouseover/mouseout handler, use hover() like so:

$('.myelement').hover(
function() {
    // my mouseover code
},
function() {
    // my mouseout code
});

And as munch suggested, start 'accepting' answers. It is a small courtesy. If you click your name, you can review your previous questions.

To accept an answer, click the checkbox to the left of the answer.

EDIT:

OK, I think I understand. To bind a 'mouseout' event (or any event) do the following:

$('#myelement').bind('mouseout', function() {
    // my code
});

PREVIOUS EDIT:

If you are saying that you want to 'stop' the current animation, then you need to call stop(). Consider the following example:

$('#box').hover(
        function() {
            $(this).stop();
            $(this).animate({height:300}, 1000);
        },
        function() {
            $(this).stop();
            $(this).animate({height:100}, 1000);
        });

#box {
    background: orange;
    width: 100px;
    height: 100px;
}

<div id='box'></box>

If the animation is in progress when you 'mouseout', calling $(this).stop() will halt the animation and start the 'mouseout' animation. If there is no animation for 'mouseout', then simply call $(this).stop().

patrick dw
@patrick you are first star :)I know this, hover or mouseover but i want to write a mouseout, for stop mouseover effects.
@jasmine - Unless I misunderstand you, that is exactly what `hover()` does. It takes two separate functions. The first gets called when you 'mouseover'. The second gets called when you 'mouseout'. Am I missing your point? **Now go check some boxes! :o)**
patrick dw
@patrick;I know the hover but;There is an iamge rotatorhttp://www.sohtanaka.com/web-design/examples/image-rotator/But I want to change "click" to "hover".But my friend that when you change "click" to "hover" and when you move the mouse from top to bottom, all tabs changed. He daid that you may use "mouseout" event.
@jasmine - I see. You need to bind the 'mouseout' event. See my new edit in the middle of my answer. You call `$('#myelement').bind('mouseout', function(){ // my code })`
patrick dw
I know the samples and examples from tutorials but i cant edit the above code.Im not professional in jquery and this rotator code is very heavy for me :( Thanks for help
@jasmine - Before I continue, I've really must insist that you go back and officially 'accept' some answers to previous questions you've posted. If you're not sure what that means, it means to click the checkbox to the left of the answer that helped you the most. It will turn green. Right now your are at a '0% accept rate'. More people will help you if they see that your 'accept rate' is closer to '100%'. Go do that, then I'll offer more help.
patrick dw
Im sorry I have checked the triangle :((Very interesting site :) I have click on this chech but accept rate already is 0!!!
**Accept rate is now 80%. Very good.** People will be more willing to help now. You can also click on the triangles to vote on answers. **Up == good answer. Down == bad answer.** You can change your vote by clicking on a triangle again.
patrick dw
Ok, now can you please tell me what you wish to accomplish? It is good to post code (html and javascript) and also give a clear explanation of what the code should do, and what it is currently doing wrong.
patrick dw