Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with DropDown Menu with .click function

    Hello, I would like to start that I really sux at this programing language so please excuse me in advance. I created a DropDown menu with .click function but I want that when you want to drop the menu down to be an arrow pointing down and when you want to up it to be an arrow pointing up. Here is a link to JSFiddle what I have done ---> Edit fiddle - JSFiddle . If you can see when you open it for first time everything is working fine but after the first time the arrow pointing down disapear and it is replaced by the arrow witch is poiting up. I know that the problem is somewhere in the "if" section but I dont have the knowledge to correct it by myself. I will really apreciate if someone find a free time and help me with this. Thanks in advance.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Methinks you are referring to Javascript since Java doesn't have a .click property.
    Moving from Java to javascript forum.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,546
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Code:
    if(DownArrow = DownArrow){
    That'll always be 1 because a) you're setting the variable DownArrow to the value of DownArrow. Even if you meant equal to (which is ==) DownArrow will always equal DownArrow. You want to have a third variable that stores the current state and toggle that.

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,927
    Thanks
    6
    Thanked 1,041 Times in 1,014 Posts
    Quote Originally Posted by Fou-Lu View Post
    Methinks you are referring to Javascript since Java doesn't have a .click property.
    Moving from Java to javascript forum.
    And I’m moving it to the JavaScript frameworks forum because this is about jQuery functionality, and jQuery is a JS framework/library.

  • #5
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,020
    Thanks
    56
    Thanked 566 Times in 563 Posts
    you would make it easier on yourself giving that img tag an id, but anyway...
    Code:
    if($(this).children("img").attr("src")==DownArrow.src){

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You may want to set the alt property of the img tag and use that instead of the src for checking.

    Edit fiddle - JSFiddle
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •