检查是否使用IF ELSE隐藏DIV

use*_*512 2 javascript jquery

我已经编写了一个JQUERY来切换DIV的可见性,这很好用,但是我需要同时调整页面的大小,但是VSE2012强调了一些大括号,说'''预期并说''的语法错误'其他'.这是我的代码:

    <script>
 $(document).ready(function () {
     $("p").click(function () {
         $("#teamtables").toggle(); 
         If ( $("#teamtables").is(":visible") ) {
             $('.mPage').css({ "height": "2600px" });
         } else {
             $('.mPage').css({ "height": "700px" });
        }
    });
 });
</script>
Run Code Online (Sandbox Code Playgroud)

Ale*_*eri 5

Javascript区分大小写,请更改Ifif 试用此:

<script>
 $(document).ready(function () {
     $("p").click(function () {
         $("#teamtables").toggle(); 
         if ( $("#teamtables").is(":visible") ) {
             $('.mPage').css({ "height": "2600px" });
         } else {
             $('.mPage').css({ "height": "700px" });
        }
    });
 });
</script>
Run Code Online (Sandbox Code Playgroud)