Results 1 to 5 of 5

Thread: Fading effect with JS

  1. #1
    Join Date
    Apr 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Fading effect with JS

    I know it's possible, but after searching and searching I can't find what I'm looking for.

    I want my banner image at the top of the page to fade in when teh page loads, I know it has something to do with opacity and what not but I don't know what to type to get it to do that, can someone please help me.
    Last edited by Snookerman; 04-30-2009 at 06:54 AM. Reason: added “Resolved” prefix

  2. #2
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    You could use jQuery, like this for instance:
    HTML Code:
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script type="text/javascrpt">
    $('div.banner').css({'opacity':0.5});
    $(function(){$('div.banner').animate({'opacity':1},1000);});
    </script>
    All you need to do is give your div a class of banner.

    Good luck!

  3. #3
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    jQuery would be your best bet, though you could do it with regular JavaScript. However, because of stupid Internet Explorer, divs won't fade like they should, so you need to use some extra JavaScript to make it work in multiple browsers. Again, jQuery, a JavaScript framework, would be your best bet. And this is if you wanna do it from scratch: fading effects with javascript
    Last edited by Snookerman; 04-29-2009 at 07:31 AM. Reason: removed jquery lmgtfy link

  4. #4
    Join Date
    Apr 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks much guys!

  5. #5
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    You're welcome MaTaX, glad to help you.

    Happy coding!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •