SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,658
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    jQuery CSS with delay. Is this the cleanest way to write it?

    Code:
    setTimeout(function () {
        $('#me').css({
    		height:'200px',
    		width:'400px',
    		background:'red'
    	});
    }, 2000);
    Thanks

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    Hi Eric,

    For me, setTimeout is the most natural way to go.
    As you are adding quite a few styles, you might want to consider making them a class.

    E.g.

    Code CSS:
    .me{
      height: 200px;
      width: 400px;
      background: red;
    }

    Code JavaScript:
    setTimeout(function () {  $('#me').addClass("me") }, 2000);

  3. #3
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,658
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    Hi Eric,

    For me, setTimeout is the most natural way to go.
    As you are adding quite a few styles, you might want to consider making them a class.

    E.g.

    Code CSS:
    .me{
      height: 200px;
      width: 400px;
      background: red;
    }

    Code JavaScript:
    setTimeout(function () {  $('#me').addClass("me") }, 2000);
    Thank you Pullo.


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
  •