Slowly enlarge text and an image with JavaScript

Discussion in 'JavaScript' started by Webed4it, Nov 19, 2010.

  1. #1
    Hi

    I am working on http://tempdomain.us.to

    I want to animate the logo and name so that they "grow" about double the size in a few seconds, not in one go.
    So How can I change the dimensions of the picture and size of the text every 100 milli seconds or so i.e. call a function a certain number of times at set intervals?
     
    Webed4it, Nov 19, 2010 IP
  2. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use an animation method from one of the Javascript frameworks, such as jQuery animate.
     
    Cash Nebula, Nov 19, 2010 IP
  3. Webed4it

    Webed4it Peon

    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks, jQuery looks like the right thing but I've tried one of the demos on my site and it does not want to work. I just copied the code. I put the link to the jquery js file in the header and even tried using a copy of it on my server but it does not work. I must be missing a something. If anyone can help I'd really appreciate it.

    http://tempdomain.us.to

    Thanks
     
    Webed4it, Nov 20, 2010 IP
  4. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Wordpress has already added jQuery here:
    <script type='text/javascript' src='http://tempdomain.us.to/wp-includes/js/jquery/jquery.js?ver=1.4.2'></script>

    This seems to work:
    
    <script type="text/javascript">
    $(document).ready(function(){
    	$("#go1").click(function(){
    		$("#block1").animate({
    			width:"90%",
    			fontSize:"24px",
    			borderRightWidth:"15px"
    		},1500);
    	});
    	$("#go2").click(function(){
    		$("#block2").animate({
    			width:"90%",
    			fontSize:"24px",
    			borderLeftWidth:"15px"
    		},1000);
    	});
    	$("#go3").click(function(){
    		$("#go1").add("#go2").click();
    	});
    	$("#go4").click(function(){
    		$("div").css({width:"200px", fontSize:"14px", borderWidth:"2px"});
    	});
    });
    </script>
    
    Code (markup):
     
    Last edited: Nov 20, 2010
    Cash Nebula, Nov 20, 2010 IP