前几天,我问了一个关于折叠div的问题([link text][fold-unfold div])。我得到的答案让我在编码工作中取得了良好的进展。但是,我的要求发生了变化。
作为所有这些网络内容的新手,我认为用表格和表格标题包装 div 会很容易。男孩,我错了吗。
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Animate my Div</title>
<style type="text/css" media="screen">
a {text-decoration: none; color: black; }
#expand {background-color: #fff;}
.description {display: none; }
.entry {margin: 0; padding: 0px;}
</style>
<script src="jquery-1.3.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".entry a").click(function() {
$(this).parents('.entry').find('.description').slideToggle(1000);
});
});
</script>
</head>
<body>
<?php
$con = mysql_connect("korg", "joe", "bob");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("wfr11", $con);
$result = mysql_query("
select title,description from webcases");
?>
<table border="1">
<thead>
<tr>
<th>title</th>
</tr>
</thead>
<?php
while ($row = mysql_fetch_array($result)) {
?><div class="entry"><tr>
<td>
<a href="#expand"><?php echo htmlentities($row['title']); ?></a>
<div class="description"><?php echo htmlentities($row['description']); ?></div>
</td>
</tr></div>
<?php
}
mysql_close($con);
?>
</table>
</body>
</html>
现在,单击工单标题不起作用。我删除了表格的所有代码,它工作正常:单击标题并展开描述
我应该能够将我的 div(扩展和描述)折叠到我的表格中,对吗?我错过了什么?