我有几个表是在 reader.php 的 foreach 中生成的
<table class="object_list_<?php echo $title; ?>">
在同一个文件中有带有 jquery 调用的链接:
<a href="#" onclick="show_object('<?php echo $itemId.','.$title; ?>')"><?php echo (string)$flat.'</a><br />'; ?>
处理程序文件 catalogue.php 中的 jQuery 函数如下所示:
<script>
function show_object(itemid,object_type){
var request = $.ajax({
url: "show_object.php",
type: "GET",
data: "id="+ itemid,
dataType: "html"
});
$(table['.object_list_' + object_type]).hide();
request.done(function(msg) {
$(".show_object").append(msg);
});
request.fail(function(jqXHR, textStatus) {
alert( "Request failed: " + textStatus );
});
}
</script>
问题出在 hide() 函数上
$(table['.object_list_' + object_type]).hide();
这是行不通的。请注意,object_type
与另一个文件中的 $title
相同,我通过 href javascript 调用传递它。
我一直在 stackoverflow 和 google 上搜索,但我就是找不到错误。它正确加载 show_object.php,但不隐藏表格。
我也试过其他几个版本,比如:
$('.object_list_' + object_type).hide();
然后先将数据添加到变量中,然后再添加到隐藏函数中……都不起作用
最佳答案
$(table['.object_list_' + object_type]).hide();
不正确,你必须使用你的第二个陈述:
$('.object_list_' + object_type).hide();
甚至更好
$('table.object_list_' + object_type).hide();
尝试在“隐藏”调用之前提醒“object_type”juste 并尝试通过 firebug/chrome 控制台手动执行它,我认为你有一个错误。
发生了什么?
关于jquery - 通过其他文件中的 jQuery 调用隐藏动态 CSS 类的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16031973/