Monday 15 February 2010

jquery - Using two var as comparison operators for if -



jquery - Using two var as comparison operators for if -

i'm scripting multi level force menu i've nail wall.

structure:

menu link 1 -> opens menu b

menu link 2 -> opens menu c

etc

when click link 1 opens menu b, when click link 2 closes menu b , opens menu c. ok

when click link 1 opens menu b, when click link 1 1 time again want close said menu , not open again.

so i'm storing opened menu level (the div stored in global var $2real) , storing target menu open same level (div stored in global var $2target) , added if ($2target != $2real) before calling function open menu (so doesn't open same menu again).

using console.log can see $2target $2real indeed same if anyway. tested using (1 != 1) , works, guess problem ($2target != $2real).

i can post code it's getting big. (and not pretty since don't have much experience)

because comparing jquery objects, not elements

if ($2target.get(0) != $2real.get(0))

or utilize is()

if ($2target.is($2real))

jquery html

No comments:

Post a Comment