gpt4 book ai didi

jquery - 单击表行时无法显示表行

转载 作者:行者123 更新时间:2023-12-01 06:00:36 25 4
gpt4 key购买 nike

我有一个表,其中包含三行组 quest_row、quest_image 和 quest_text。最初,只有 quest_row 可见 - 这是有效的。它显示问题编号。当用户单击表的 quest_row 行时,我希望它显示下一个 quest_image 和 quest_text 行。这是代码:

<table width="90%">
<tr>
<td>Questions <?php echo "how many = $how_many"; ?>
</td>
</tr>
</table>
<?php
for ($i=1;$i<=$how_many;$i++) {
$row=mysqli_fetch_assoc($result);?>
<table name="quest_info" id="quest_info" border=1 width="100%">
<tr class="quest_row">
<td bgcolor="#00CCFF">
Question# <?php echo $i; ?>
</td>
</tr>
<?php if ($row["image"] <> NULL) { ?>
<tr class="quest_image" >
<td class="quest_image" id="quest_image<?php echo $i; ?>">
<img src="<?php $pic = $row['image']; echo $base_path . $pic; ?>" width="200" />
</td>
</tr>
<tr class="quest_text" >
<td class="quest_text" id="quest_text<?php echo $i; ?>"><?php echo $row["question"]; ?></td>
</tr>
</table>
<?php
} else {
?>
<tr class="quest_image" >
<td class="quest_image" id="quest_image<?php echo $i; ?>">
</td>
</tr>
<tr class="quest_text" >
<td class="quest_text" id="quest_text<?php echo $i; ?>"><?php echo $row["question"]; ?></td>
</tr>
</table>
<?php
} ?>
<?php
} ?>
<script type="text/javascript" src="../jquery/jquery/jquery-1.7.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".quest_text").hide();
$(".quest_image").hide();
$("#quest_info").click(function(){
var trigger = event.target;
alert('target = ' + target);
if(trigger.className == 'quest_row')
{
$(trigger).closest('tr').next('quest_image').show();
$(trigger).closest('tr').next('quest_text').show();
}
});
});
</script>

不知道为什么这不起作用。

最佳答案

JQuery 在显示/隐藏表行时出现问题。尝试使用 DIV

关于jquery - 单击表行时无法显示表行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11808107/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com