Key press dont work on dynamicly created element [duplicate]

This question already has an answer here:

i am trying to add a new span of tag inside tags div.
my problem is that the code under span[id="newtag"] doesnt
work. how can i make this code work?

            $(document).ready(function () {
            $('#tags').on("click", function () {
                    $(this).append('<span id="newtag" contenteditable="true"></span>');
                if (k.which == 13 || k.which == 32) {

Source: New Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.