Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorJack
    • CommentTimeJun 14th 2006
     permalink
    Hi guys

    I'm using a very simple jquery script to emulate the :hover pseudo class in explorer, but I'm getting some intermittent errors. Sometimes it would work, and other times it wouldn't.

    here''s the link (you might have to refresh a few times to see the problem)

    the jquery script:

    window.onload = function(){
    $("#main ul li a").mouseover(function(){my_hover(this)});
    }

    function my_hover(e){
    $("#main ul li a.selected").removeClass('selected');
    $(e).addClass('selected');
    }


    I've tried everything I can think of, but nothing's worked - not even position:relative ; ]. Such a simple effect really shouldn't have any problems, but I'm out of ideas..

    Thanks for any suggestions
    •  
      CommentAuthornifkin
    • CommentTimeJun 14th 2006
     permalink
    1- starting with invalid code just makes debugging that much more difficult.

    2- jQuery has a built in method for that may help with the things you're trying to do.

    $(document).ready(function(){ // unless you're using document.write() code, this will work a little nicer than window.onload
        $('#main ul li a').hover(
            function(){
                // "mouseover" events go here
                $(this).addClass('selected');
            },
            function(){
                // "mouseout" events go here
                $(this).removeClass('selected');
            }
        );
    });
    • CommentAuthorJack
    • CommentTimeJun 15th 2006
     permalink
    hey, thanks for the input, but the problem persists, even with valid code and using the hover function. (check original url)

    I think I will use some ugly inline javascript for the time being..
  1.  permalink
    I notice that you are using SIFR. That uses document.write to insert the Flash headings which can mess with jQuery's $(document).ready() function - although there is talk that version 1.0 of jQuery will fix this. See if it works with $(document).load() instead for now.
Add your comments
    Username Password
  • Format comments as (Help)