Javascript 在单击链接时获取Div ID

Javascript 在单击链接时获取Div ID,javascript,jquery,html,click,fadeout,Javascript,Jquery,Html,Click,Fadeout,我想做的是在点击框的十字后淡出一个框,但即使通过谷歌搜索也无法让它工作。我是在点击div it self时用$(这个)让它工作的,但我希望它在点击十字时工作 <?php require "global.php"; $select_staff = mysqli_query($database_connection,"SELECT * FROM staff_info"); if(!$select_staff) { die("Database Error"); } while($staff

我想做的是在点击框的十字后淡出一个框,但即使通过谷歌搜索也无法让它工作。我是在点击div it self时用$(这个)让它工作的,但我希望它在点击十字时工作

<?php 
require "global.php";
$select_staff = mysqli_query($database_connection,"SELECT * FROM staff_info");

if(!$select_staff) {
die("Database Error");
}

while($staff_info = mysqli_fetch_array($select_staff)) {
$div_id = $staff_info['div_id']; // assuming you have an id field in your DB
$account_name = $staff_info['account_name'];
$position = $staff_info['position'];
$description = $staff_info['description'];
echo "

<div class='staff_boxes' id='staff_boxes_$div_id'> 
 <a href='#' class='delete_button'> X </a>";
echo"
<h2>$account_name</h2>
$position
<p>$description</p>
</div> ";
}
?>

<script>
$( document ).ready(function() {




$('div').click(function() {
var myScript = document.getElementById('myScript');
 $(this).removeAttr('id').fadeOut();
 });








});
</script>








<style>

.staff_boxes {
width: 250px;
min-height: 150px;
border: 4px solid gold;
background:#C2DAD7;
/*to reduce float drop issues in IE*/
word-wrap: break-word;
}

.staff_boxes {
margin-left: 63px;
float: left;
}



/**Clear floats after the boxes**/

</style>

以父对象为目标,如下所示:

$('.delete_button').click(function() {
    $(this).parent().fadeOut();
    return false; //Without this the browser may scroll to the top of the page
});

非常感谢,伙计:我不知道为什么我没有尝试,这只是一行简单的代码lol,可能需要做更多的JQuery教程,我只是从PHP学习。投票支持你是理所当然的;)我也有返回错误;在以前没有两者都重新添加它,但应该的