親で<div>
使用した後にコンテンツを追加しようとしています。empty()
しかし、どういうわけか、それはうまくいきません。なぜこれがうまくいかないのですか?私がempty()
物を使わなければうまくいきます。しかし、なぜ使用した後ではありませんかempty()
私がしようとしているのは、リンクを含む親を空にする.acceptUser
か.rejectUser
、新しいリンクを追加することです。新しいコンテンツはparent div
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Side bar poll thingy</title>
<script type="text/javascript" src="http://localhost/site/scripts/jQueryCore.js"></script>
<script type="text/javascript" src="http://localhost/site/scripts/rsCore.js"></script>
<script type="text/javascript" src="http://localhost/site/scripts/jquery.validate.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.acceptUser, .rejectUser').click(function() {
var action = $(this).attr('class');
var type = $(this).data('id');
console.log(action+' '+type);
console.log($(this).parent());
$(this).parent("div").empty();
// Wont work : $(this).parent("div").after("<div class='flag'>Success</div>");
// Wont work : $(this).parent("div").append("<div class='flag'>Success</div>");
});
});
</script>
</head>
<body>
<div id="container">
UserName : Norman | SignedUp: 10-09-2013 | SignedUp Location: US
<div class="adminLinks">
<span class="acceptUser" data-id="24">Accept</span>
<span class="rejectUser" data-id="24">Reject</span>
</div>
</div>
</body>
</html>