Problem with jquery selectors.

jquery , selector Philadelphia, United States
  • 8 years ago

    I am trying to use this jquery slide function that i found online. It's a very basic slide plugin i suppose, which selects a div using the div's id tag. I wanted to make my menu hide/reveal multiple divs and therefore I modified this function that I keep in my .js file to make things work theoretically. But for some reason I cannot get this to work and I think that it might be that my selectors are implemented wrong in my js file. Here is an example of what I've got which seems to work except for when I try my modified code:

    $(document).ready(function() {

        $(".fadeNext_home").click(function(){  
    
                $("#home").fadeSliderToggle()
    
                 return false;
    
        })
    

    });

    This is the code that works in my js file:

        caller = this
    

    if($(caller).css("display") == "none"){

    $(caller).animate({

    opacity: 1,

    height: 'toggle'

    }, settings.speed, settings.easing);

        }else{
    
                $(caller).animate({
    

    opacity: 0,

    height: 'toggle'

    }, settings.speed, settings.easing);

        }
    

    };

    And this is a modified version with my own selector that does not work. And I think it's because of the way that I'm trying to interact with an id tag that was not passed to the js file:

        if($(caller).css("display") == "none"){
    
    
    
                if($("#home").css("display") != "none"){
    
                        $("#home").animate({
    
                                opacity: 0,
    
                                height: 'toggle'
    
                        }, settings.speed, settings.easing);
    
                }
    

    I'm new to jquery (obviously) and would appriciate any help. Thanks so much!

    thanks, wes

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves” - Alan Kay