Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Expand Div

  1. #1
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Expand Div

    How can I use javascript to make a div expand (say, in width), but make it more like an animation, so perhaps every so many milliseconds the div would grow by 1px until it reached the certain width needed?

  • #2
    New Coder
    Join Date
    Dec 2005
    Location
    Dallas, TX
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    function expand_div(divID) {
        var theDiv = document.getElementById(divID);
        theDiv.width = theDiv.width + 1;
        if(theDiv.width > 1024) {  // Insert whatever width you want it to stop at here.
            return;
        } else {
            setTimeout('expand_div('+divID+')', 250); // Set to do it every half-second. Again, insert whatever time you want.
        }
    }
    I didn't actually test it, but it SHOULD work. If not, let me know.
    Owner - Osiris Incorporated

    PHP and MySQL pro, and always willing to help.


  •  

    Posting Permissions

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