0

i have a div that have some effect inside and the animation work perfectly but when i clone it the effect not work any more? here is the code:

 $(document).ready(function () {
     $('button').bind('click', function () {
         var parents = $(this).parents('.display');
         parents.clone(true).appendTo('body');
     });
     $('image')..fadeIn("slow"); 
 });
<html>
    <div style="display:block; position:relative;" class="display">
                <div>
                    <button class="close">close</button>
                    <h3>Camera Ready</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolor ea voluptatem cupiditate nemo porro ipsam possimus expedita totam ullam harum. Assumenda, sit illo nesciunt itaque magni recusandae aspernatur ex veritatis voluptate placeat. Nisi, labore, explicabo accusamus tempora odit earum incidunt expedita at ad! Ut, repellat, sint tempora perferendis aut obcaecati optio repellendus cupiditate iusto quis eligendi laudantium non incidunt hic eius dolore deleniti! Aspernatur, aliquid, sed, quae in quibusdam officia id impedit ab earum laboriosam aut numquam labore cum quaerat fugiat ex aperiam ducimus rem ullam repellat. Atque, explicabo, saepe, qui voluptates blanditiis pariatur quam aliquam vero at ad vitae?</p>
                </div>
                <img src=""/>
            </div>
</html>
architesa
  • 79
  • 2
  • 7

1 Answers1

0

You have attached event for li for static element not for dynamically created li 's. Use this instead

$(".display").on("click", "li", function(){
     $(this).animate //whatever
});
Anupam
  • 7,966
  • 3
  • 41
  • 63
  • I think that should be $('ul').on('click, 'li' function(){ $(this).animate//whatever }) because the li's are added dynamically, you should pick their parent (who is available when this code runs) – Tdelang Jul 23 '13 at 08:45
  • @Tdelang Yes thats the alternative for `delegate()` mine is an alternative for `bind()`. [This post](http://stackoverflow.com/a/8065403/456135) would make it much clear – Anupam Jul 23 '13 at 08:49
  • sorry i have another problem i want some picture fade in but the live is not working could you please help me again – architesa Jul 23 '13 at 10:26
  • @architesa I will need your code to help. The `fadeIn()` method you have shown in your post has two .(dot) before it – Anupam Jul 23 '13 at 10:59
  • my code is too long i have some effect that load automaticaly but when i clone it . dosent load the effects any more – architesa Jul 23 '13 at 11:06
  • Sorry but without looking at the code I cannot guess the problem. You can post a new question with specific code, and give reference to this post. – Anupam Jul 23 '13 at 11:12