繁体   English   中英

用php加载页面,但用jquery淡入

[英]Loading pages with php, but fade-in with jquery

我用php动态地在我的页面中加载内容。 我想添加一个很好的效果,例如使用jQuery进行淡入。

但我希望我的页面在用户关闭javascript的情况下仍能正常工作。

这是我的php代码,用于加载内容:

/// load page content
        $pages_dir = 'content';

        if(!empty($_GET['p'])) {

            $pages = scandir($pages_dir, 0);
            //delete . and ..
            unset($pages[0], $pages[1]);

            $p = $_GET['p'];

            // only files that are in the array can be loaded
            if (in_array($p. '.php', $pages)) {
                include($pages_dir. '/'.$p. '.php');    

            } else {
                echo 'This page is not available';
            }
        } else {
            include($pages_dir. '/index.php');
        }

这就是我所做的。 用id“ fadein”将div包裹在我的PHP代码周围,然后使用以下jquery代码:

$(function(){
            $('#fadein').hide();
            $('#fadein').fadeIn();

        });

简单

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM