我正在尝试在其父级上<div>
使用后将内容添加到 a 中。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>