Grow your CSS skills. Land your dream job.

jquery hover out

  • # December 24, 2009 at 8:04 pm

    i’m trying to do a little trick with jquery to make a image disappearing when hovered and showing a text under it.

    everything is working fine, but i don’t know why, is not coming back to the original image when i move the mouse out.

    this is the code:

    Code:
    $j(‘#wrapper_superouter #wrapper_outer #wrapper_inner #wrapper #bg_page #content #post #persone #persona img.fvezzoli’)
    .hover(function(){ $j(this).addClass(‘elimina_img’);
    $j(‘#wrapper_superouter #wrapper_outer #wrapper_inner #wrapper #bg_page #content #post #persone #persona p.fvezzoli’).addClass(‘mostra_p’);},
    function(){ $j(this).deleteClass(‘elimina_img’);});

    i have this class called elimina_img that is just a Css visibility: hidden.

    i’m feeling so stupid ’cause it’s a basic thing, i’ve looked to some tutorials and i cant find the error.

    cheers.

    # December 25, 2009 at 10:06 am

    you can see it here:

    http://www.apertamente.eu/site/le-persone

    thanks!

    # December 25, 2009 at 10:48 am

    You can try to reveal the paragraph instead of hiding the image like so :

    Code:
    < ?xml version="1.0" encoding="UTF-8"?>
    < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


    The paragraph you want to reveal.




    Paste this into an html file and load it, I think this is the effect you are trying to achieve.

    Here’s the javascript part if you just want that :

    Code:

    # December 25, 2009 at 4:26 pm

    thanks a lot.

    i’ve tried your idea but it’s not working. since i cant set the image as a background ’cause i get the path from wordpress.

    i’ve done something like that:

    Code:
    $j(‘#wrapper_superouter #wrapper_outer #wrapper_inner #wrapper #bg_page #content #persone #persona img.Eugenia-Grazioli’)
    .hover(
    function(){
    $j(‘#wrapper_superouter #wrapper_outer #wrapper_inner #wrapper #bg_page #content #persone #persona #testo.Eugenia-Grazioli’).stop(true, true).fadeIn(100);
    },
    function(){
    $j(‘#wrapper_superouter #wrapper_outer #wrapper_inner #wrapper #bg_page #content #persone #persona #testo.Eugenia-Grazioli’).stop(true, true).fadeOut(100);
    });

    in firebug i can see then property of the paragraph, in this case the Div #testo, change correctly, but i cant see them in the browser ’cause the img is always there. I’ve tried to combine my old script with yuors but as a result i get the image flickering when i’m hover it.

    thanks a lot

    Fede

    # December 26, 2009 at 3:55 am

    Ok let’s see :

    Do you have a reset stylesheet? If not I strongly suggest you you grab one and paste it at the top of your stylesheet.
    Speaking of which, make sure that both the div and the paragraph have the same dimensions in it.

    What do you mean you are getting the path from wordpress? Because it shouldn’t matter, the image should be hosted on your server regardless, it’s only a matter of grabbing it’s url.

    I’ve been on your website, something happens when you hover over your image so I’m pretty sure it’s just a javascript issue, try to replace the "$j" by just "$" in your code. Also I don’t think you need to specify so many id’s to target your div. If the div you hover is #testo, then just try :

    $(‘#testo’).hover("your functions here");

    Hope it helps.

    # December 26, 2009 at 5:40 am
    "Caramel_boy" wrote:
    Ok let’s see :

    Do you have a reset stylesheet? If not I strongly suggest you you grab one and paste it at the top of your stylesheet.
    Speaking of which, make sure that both the div and the paragraph have the same dimensions in it.

    What do you mean you are getting the path from wordpress? Because it shouldn’t matter, the image should be hosted on your server regardless, it’s only a matter of grabbing it’s url.

    I’ve been on your website, something happens when you hover over your image so I’m pretty sure it’s just a javascript issue, try to replace the "$j" by just "$" in your code. Also I don’t think you need to specify so many id’s to target your div. If the div you hover is #testo, then just try :

    $(‘#testo’).hover("your functions here");

    Hope it helps.

    yes of course i have a reset.
    there was some difference in the wrappers dimensions, i’ve modified them now.
    I’ve put the text before the img now.
    take a loot at it…
    it’s flickering when the mouse is over, and you can see a bit of the image right under the main wrapper.

    this is the code:

    Code:
    $j(‘#persona img.Eugenia-Grazioli’)
    .hover(
    function(){
    $j(‘#persona #testo.Eugenia-Grazioli’).stop(true, true).fadeIn(100);
    },
    function(){
    $j(‘#persona #testo.Eugenia-Grazioli’).stop(true, true).fadeOut(100);
    });

    thanks alot…

    # December 26, 2009 at 9:12 am

    I finally solved it!
    i got the flickering effect cause i was triggering the fade out on the image and not on the wrapper!

    thanks a lot for you help…

    # December 27, 2009 at 10:50 am

    Well glad I could help man! Happy to see that it works.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".