SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Replicate this rollover (example):

    Hey guys, first post here, I am hoping I can have some guidance trying to create a very similar rollover effect as this one:

    www.sshvm.com

    If there is jquery or javascript already available for this that would be great, or if you think I should start from scratch that's fine I am experience in javascript but would appreciate some guidance. Thanks!
    Last edited by Mittineague; Jul 31, 2011 at 15:27. Reason: OP forgot to turn off auto-title

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by yamahaalex37 View Post
    If there is jquery or javascript already available for this that would be great, or if you think I should start from scratch that's fine I am experience in javascript but would appreciate some guidance. Thanks!
    The technique used there is to add a CSS class name to element, in the case of the demo, to the section element.

    It's a two-step process.

    1. When one of the sections is hovered over, the CSS class name specifying the active panel is removed from all of them.
    2. Then, the CSS class name specifying the active panel is added to the one that is being hovered over.

    Let's see if we can find out how they do it on their site.
    Aha, here it is in their code, in the saas.js file, and it's exactly as described.

    Code javascript:
    var $gridSections = $grid.find('section');
    $gridSections.hover(function () {
        $gridSections.removeClass('on');
        $(this).addClass('on');
    });

    They use 'on' there, but typically in practice you would use a term that more appropriately describes the intent, such as 'active'
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •