How do I make JQuery treat new elements in the same way that the original elements in a html file are treated? For example, consider the following example:
<!DOCTYPE html>
<html>
    <head>
        <title>simple click to switch</title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
        <script type="text/javascript">
            $edit = "<div>edit</div>";
            $(document).ready(function () {
                $("div").click(function () {
                    $(this).after($edit);
                    $edit = $(this);
                    $(this).remove();
                });
            });
        </script>
    </head>
    <body>
        <div>switch me</div>
    </body>
</html>
I expected this block of JQuery to allow me to toggle between the divs "switch me" and "edit", on clicking. However, the result is, it recognises the original div, allowing a single "toggle". But the newly added div is not recognised by JQuery. The div can only be toggled once. How do I solve this problem?
 
    