Link to home
Start Free TrialLog in
Avatar of degaray
degaray

asked on

Delete appended div with jquery

Hello,

I am trying to delete a div after it was dynamically loaded by jquery but it does not remove it.

Please see my code, any guesses on how to delete it?
<html>

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>

<body>
<div class="ap">some text</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
	$(".ap").click(function(){
		$(".ap").after("<div><div class='delete'>x</div>aaaa</div>");
	});
	$(".delete").click(
	function(){
		$(this).parent().remove();
		}
	);
</script>

</body>

</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of degaray
degaray

ASKER

Thanks a lot!!!!