所以最近我一直在研究js的一点点。JavaScript jQuery隐藏/显示功能
所以,基本上,我的问题是,我需要隐藏参数中传递的任何内容,或者如果它已经隐藏,则显示它。
这里是我的代码:
<script type='text/javascript'>
<!--
function toggleReport(table){
//the table argument is the table's id
alert(table); //to check that the name of the table is right
if($('#table').is(':visible')){ //check if visible
$('#table').hide(); //if so, hide it
alert('hide'); //send a message that it is now being hidden
}else{ //if already hidden
alert('show'); //send a message that it is now being shown
$('#table').show(); //show the table
}
}
//-->
</script>
但是,它不工作....它发送警报,一切是正确的,但是,它并不隐藏或显示表.. ..
但是,如果我尝试这样做:
<script type='text/javascript'>
<!--
function toggleReport(){
//removed the argument
alert('table_1');
if($('#table_1').is(':visible')){
$('#table_1').hide();
alert('hide');
}else{
alert('show');
$('#table_1').show();
}
}
//-->
</script>
它的工作原理!为什么这样?因为即时通讯将在网站上有很多表格和其他需要隐藏和显示的内容,我不想为每个表格创建新功能..:/
请帮帮我!
谢谢!
谢谢!你的工作实际上并不复杂! – Baruch