hi all,
i am using the code below to hide some content, the first part works
ok & hides the content as expected but i cant get the second part to
work - i.e. showing the content again - any ideas?
i don't want to use toggle as i am displaying the content based on a
cookie value & when the cookie is set, it takes 2 clicks to display
the content if it was hidden by the cookie.
> i am using the code below to hide some content, the first part works
> ok & hides the content as expected but i cant get the second part to
> work - i.e. showing the content again - any ideas?
Can you show a sample of the markup, or better yet link to a test page?
> > i am using the code below to hide some content, the first part works
> > ok & hides the content as expected but i cant get the second part to
> > work - i.e. showing the content again - any ideas?
> Can you show a sample of the markup, or better yet link to a test page?
Ah, I think I see it, but I should have seen it earlier.
I'm going to assume your two .click() methods are inside a .ready()
handler or other block that doesn't execute until the markup is there.
Remember that the .click() method sets an event handler for the
elements matching the selector **at the time the .click() method is
called**.
So your handler for ".min" attaches to the elements that initially
have a class of min. There aren't any elements with the class max so
that one does nothing. That explains why the min works but the max
doesn't.
It looks like you're using the min and max classes to show some sort
of image defined by css, so you probably want to keep those the way
they are. If all your entries are initially at min, you could just
attach a single handler with the ".min" and handle the toggling inside
that one handler. If some start at min and some at max, that wouldn't
work.
What I would do is create another class, say minmax, and attach the
event handler with that. Inside the handler, see if the current class
is min or max and do the opposite.
i am using the href as i want to use a hover image, but if it is far
down the page & a user clicks on it to show/hide the content, the
browser scrolls back to the top of the page.
any ideas?
On May 12, 1:45 am, Dave Methvin <dave.meth...@gmail.com> wrote:
> Ah, I think I see it, but I should have seen it earlier.
> I'm going to assume your two .click() methods are inside a .ready()
> handler or other block that doesn't execute until the markup is there.
> Remember that the .click() method sets an event handler for the
> elements matching the selector **at the time the .click() method is
> called**.
> So your handler for ".min" attaches to the elements that initially
> have a class of min. There aren't any elements with the class max so
> that one does nothing. That explains why the min works but the max
> doesn't.
> It looks like you're using the min and max classes to show some sort
> of image defined by css, so you probably want to keep those the way
> they are. If all your entries are initially at min, you could just
> attach a single handler with the ".min" and handle the toggling inside
> that one handler. If some start at min and some at max, that wouldn't
> work.
> What I would do is create another class, say minmax, and attach the
> event handler with that. Inside the handler, see if the current class
> is min or max and do the opposite.
> i am using the href as i want to use a hover image, but if it is far
> down the page & a user clicks on it to show/hide the content, the
> browser scrolls back to the top of the page.
> any ideas?
> On May 12, 1:45 am, Dave Methvin <dave.meth...@gmail.com> wrote:
> > Ah, I think I see it, but I should have seen it earlier.
> > I'm going to assume your two .click() methods are inside a .ready()
> > handler or other block that doesn't execute until the markup is there.
> > Remember that the .click() method sets an event handler for the
> > elements matching the selector **at the time the .click() method is
> > called**.
> > So your handler for ".min" attaches to the elements that initially
> > have a class of min. There aren't any elements with the class max so
> > that one does nothing. That explains why the min works but the max
> > doesn't.
> > It looks like you're using the min and max classes to show some sort
> > of image defined by css, so you probably want to keep those the way
> > they are. If all your entries are initially at min, you could just
> > attach a single handler with the ".min" and handle the toggling inside
> > that one handler. If some start at min and some at max, that wouldn't
> > work.
> > What I would do is create another class, say minmax, and attach the
> > event handler with that. Inside the handler, see if the current class
> > is min or max and do the opposite.