jquery div not respnding to other javascript/jquery methods -
i have added 1 div inside div using $(select).append() method want close on click on image hav added image , $(select).button().click( { $(select).hide() }); on clicking close image nothing happens....
$(document).ready(function() { $("#subcre").click(function() { cust = $("#customer").val(); address = $('#address').val(); phone = $('#phone').val(); amt = $('#initamount').val(); user = '<%= session.getattribute("user").tostring()%>'; type = '<%=session.getattribute("type").tostring()%>'; alert(cust + address + phone + amt + user + type); $.post("../processor/proc2.jsp", { customer: cust, address: address, phone: phone, initamount: amt, user: user, type: type }, function(data, status) { if (status === "success") { if(data.length == 11) { $("#systemmessages").append('<div class="msg draggable"><img class="close" src="../mime/close.png">account added</div>'); // **here 1 div } else { $("#systemmessages").append('<div class="errormsg draggable"><img class="close" src="../mime/close.png">'+ data + '</div>'); //** here 2nd div } $("#customer").val(""); $('#address').val(""); $('#phone').val(""); $('#initamount').val(""); } }); $(".close").button().click(function() { $(".close").parent().css("visibility", "hidden"); }); });
you need use event delegation dynamically appended elements
$('#systemmessages').on('click','.close',function(){ $(this).parent().css("visibility", "hidden"); });
event delegation --->
https://learn.jquery.com/events/event-delegation/
Comments
Post a Comment