在php文件中添加了jquery jAlert代码,但它';It’不起作用


Added jquery jAlert code inside php file but it's not working

我在php代码中为一个警报添加了jAlert框。正常的window.confirm()工作得很好,但我添加了jAlert,它不工作。我为jAlert提供了css和js文件。

 echo "
        <script type='"text/javascript'">
                $.fn.jAlert({
            'title': 'Activity :- Search',
            'message': 'Are you sure you want to display more than 250 activities?',
            'theme': 'info',
            'btn': [
                {'label':'Yes', 'cssClass': 'green', 'closeOnClick': true, 'onClick': function()
                { 
                    window.location.href = ('home.php');
                } 
                },
                {'label':'No', 'cssClass': 'red', 'closeOnClick': true, 'onClick': function()
                { 
                    window.location.href = ('logout.php');
                } 
                }
            ],
            'autofocus': 'btn:first'                
        });

        </script>
    ";

请帮我解决这个问题。提前感谢

将$.fn.jAlert封装在$(function()中{

在执行代码之前,插件似乎还没有加载。

决赛应该是这样的:

echo "
    <script type='"text/javascript'">
           $(function(){
            $.fn.jAlert({
        'title': 'Activity :- Search',
        'message': 'Are you sure you want to display more than 250 activities?',
        'theme': 'info',
        'btn': [
            {'label':'Yes', 'cssClass': 'green', 'closeOnClick': true, 'onClick': function()
            { 
                window.location.href = ('home.php');
            } 
            },
            {'label':'No', 'cssClass': 'red', 'closeOnClick': true, 'onClick': function()
            { 
                window.location.href = ('logout.php');
            } 
            }
        ],
        'autofocus': 'btn:first'                
    });
    });
    </script>
";
相关文章: