as stated above, you should use .delegate()
instead of .live()
.
To use delegate
all you have to do is specify the parent in which you will listen, and the selector on which it will act.
Try the following:
<script> $(function(){ var Maindiv = $("#MainDiv"); var toClone = $("#toClone"); $("#MainDiv").delegate('#Statusess','change', function () { if ($(this).find(":selected").val() != "") { if ($(this).parent().prev().find(":selected").val() != "") { $(this).parent().parent().find("#loadingGif").attr("style", "display: inline;"); $.ajax({ url: '/echo/html/', type: 'POST', success: function (data, status) { data = "1"; if (data != "0") { $(this).parent().parent().find("#Ok").attr("style", "display: inline;"); $(this).parent().parent().find("#noOk").attr("style", "display: none;"); } else if (data == "0") { $(this).parent().parent().find("#Ok").attr("style", "display: none;"); $(this).parent().parent().find("#noOk").attr("style", "display: inline;"); } var div = $('div:eq(0)', Maindiv).clone(); Maindiv.append(div); } }); $(this).parent().parent().find("#loadingGif").attr("style", "display: none;"); } } }); }); </script>
Here you have a working jsfiddle , also here is a link to link to . delegate () .
source share