Hi Daniele,

at the time you're attaching the click event, the paragraph has no
class and thus it will accept the click event (which then works
"forever"). You have to rebind all the events after the DOM has been
changed.

There's some interesting reading about events on Karl Swedberg's
famous website :)
http://www.learningjquery.com/2008/03/working-with-events-part-1
http://www.learningjquery.com/2008/05/working-with-events-part-2

--
Bohdan

On Jul 18, 6:02 pm, Daniele <[EMAIL PROTECTED]> wrote:
> Hi. I am doing a simple thing summarized as follow: when i click on a
> paragraph i want it to do something only the first time.
>
> I was able to do it using "one( type, data, fn )" but before that I
> tried using a different approach like this:
>
> $("p:not(.open)").click(function () {
>     // do something ...
>     $(this).addClass("open");
> )};
>
> or
>
> $("p").not(".open").click(function () {
>     // do something ...
>     $(this).addClass("open");
> )};
>
> I know I am missing some basics here but I'm out of ideas.

Reply via email to