【发布时间】:2011-05-18 01:22:56
【问题描述】:
几天前,我问了一个关于折叠 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(扩展和描述)折叠到我的表格中,对吗?我错过了什么?
【问题讨论】:
-
....那里不能有
<div>。 -
你能说得具体点吗?
-
他的意思是。您只能将内容放在 td 或 th 内。您可能应该使用它开始变得更有意义了。我想我搞砸了我的嵌套......我不完全确定您为什么将其包装在表格中。一个简单的手风琴风格系统不工作吗? docs.jquery.com/UI/Accordion 有一个示例,说明如何在单击标题时隐藏某些内容。
标签: php jquery html html-table fold