CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   Fade in & slideup thingy (http://www.codingforums.com/showthread.php?t=274962)

marekrndr 10-02-2012 06:57 PM

Fade in & slideup thingy
 
Hey,

I'm trying to learn Javascript and I'm stuck in the following - I got a #filesdown_ (class that activates the js), an img.filesfade_ (button that slides ul.files_menu down and fades itself to 0). When the mouse is out of #filesdown_ the ul.files_menu slides up again. I can't figure out how to keep the button opacity at 0 and the ul.file_menu down if the button or menu is hovered.

Code:

$(document).ready(function () {
    $('#filesdown_').mouseenter(function () {
    $('ul.files_menu').slideDown('medium');
        $('img.filesfade_').stop().animate({"opacity": "0"}, "fastmedium");
    });
    $('ul.files_menu').mouseleave(function () {
    $('ul.files_menu').slideUp('medium');
        $('img.filesfade_').stop().animate({"opacity": "1"}, "fast");
    });
    $('img.filesfade_').mouseleave(function () {
    $('ul.files_menu').slideUp('medium');
        $('img.filesfade_').stop().animate({"opacity": "1"}, "fast");
    });
});


sunfighter 10-03-2012 05:30 AM

You are studying jquery. It's a framework of javascript. Learning jquery is not the same a s learning javascript. But there is nothing wrong with jquery.

For starters this:
$('ul.files_menu').slideDown('medium');
No medium speed use "slow", "normal", "fast" or the actual time in milliseconds.

To control the opacity use fadeIn or fadeOut
ex:
Code:

<script type='text/javascript' src='javascript/jquery.js'></script>
<script type="text/javascript">
$(document).ready(function () {

    $('#button').mouseenter(function () {
                $('img.filesfade').fadeOut();
        });

    $('#button').mouseleave(function () {
                $('img.filesfade').fadeIn();
        });

});
</script>

<button id="button">PUSH</button><br />
<img border="2" class="filesfade" src="images/6.png">

Again no fastmedium. use the same speeds given above.

Good place to learn basic jq is here http://www.w3schools.com/jquery/default.asp

marekrndr 10-03-2012 12:38 PM

Hey,

thanks for the answer! I've got the button as one element and the slide down menu as the second. I should need to use if statement to check wether one of the 'hover areas' are being targeted so the menu wont slide up or the button wont fade back,.

sunfighter 10-03-2012 11:19 PM

Quote:

I should need to use if statement to check wether one of the 'hover areas'
You could use different classes or id's and the IF is not needed.


All times are GMT +1. The time now is 03:26 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.