最近、私は少しのjsに取り組んでいます。
したがって、基本的に、私の問題は、パラメーターに渡されたものを非表示にするか、既に非表示になっている場合は表示する必要があることです。
これが私のコードです:
<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>
できます!なぜそうなのですか?なぜなら、私はウェブサイト上に多くのテーブルや、隠したり表示したりする必要がある他のものを持ち、それぞれに新しい関数を作りたくないからです.. :/
私を助けてください!
ありがとう!!