Rails beginner
Rails beginner

Reputation: 14514

Why is opacity not added to divs that are added?

I am having that problem that opacity is not added to tfrhe selected divs.

Here do I have a fine working example what I am trying to do: http://jsfiddle.net/PRZ5J/13/

Here have I added the code from the first example with some other Jquery: http://jsfiddle.net/gDChA/74/

The problem is that the added input field and its divs does not have the same function and opacity as the first example.

Upvotes: 0

Views: 56

Answers (1)

Joseph Marikle
Joseph Marikle

Reputation: 78550

You have to use the "live" function in jquery to ensure that newly created elements have any event listeners you set up. In this case, instead of applying the .click listener to all the color squares, you would want to use a .live click event. e.g.

$('.blackDiv,.blueDiv,.redDiv').live("click", (clickopa));

and that will get you your event back. I did a little tweaking of the function but this should work for you.

Demo

Upvotes: 1

Related Questions