简体   繁体   English

如何在页面的一部分中包含JS脚本?

[英]How to include a JS script to a part of the page?

Noob needs help! 新手需要帮助! Is it possible to include a script within a part of the page? 是否可以在页面的一部分中包含脚本? The trouble is theat one part of the form needs JQuery chained and the other needs regular JQuery. 问题在于,表单的一部分需要链接JQuery,而另一部分则需要常规JQuery。 Here's the code: 这是代码:

$result=$result."
        Выберите тематику: <select id='thematic' name='thmsel'>
            <option></option>
            <option value='fb'>Стадион</option>
            <option value='sch'>Школа</option>  
            <option value='sw'>Бассейн</option>                              
        </select>
        Выберите раздел: <select id='catch' name='catsel'>
            <option></option>
            <option value='news' class='fb'>Новости</option>
            <option value='articles' class='fb'>Статьи</option>
            <option value='news' class='sch'>Новости</option>
            <option value='articles' class='sch'>Статьи</option>    
            <option value='news' class='sw'>Новости</option>
            <option value='articles' class='sw'>Статьи</option>
        </select>
        Выберите категорию: <select id='chap'name='chsel'>
            <option></option>
            <option value='world' class='news'>Мировые новости</option>
            <option value='rf' class='news'>Новости РФ</option>
            <option value='vlg' class='news'>Новости города</option>
            <option value='our' class='news'>Наши новости</option>
            <option value='useful' class='articles'>Полезное</option>
            <option value='humour' class='articles'>Юмор</option>   
        </select>
        <br>
        <script src='jquery.chained.min.js'></script>
        <script charset='utf-8'>
        $(function(){
            $('#catch').chained('#thematic');
            $('#chap').chained('#catch');
        });
        </script>

        ";


        $result=$result."
        <script src='//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
        Заголовок новости: &nbsp <input type='text' name='title' value='' size='158'>
        <input type='hidden' name='state' value='save' />
        <textarea id='editor1' name='txt'></textarea></br>
        <submit type='button' value='Save'></form>
        <script type='text/javascript'>
                var ckeditor1 = CKEDITOR.replace( 'editor1' );
                AjexFileManager.init({
                    returnTo: 'ckeditor',
                    editor: ckeditor1
                });
            </script>

        <script type='text/javascript'> 
            function save()
            {
                for ( instance in CKEDITOR.instances )
                        CKEDITOR.instances['editor1'].updateElement();
                var data = $('#tdescription').val()

                $.ajax({
                type: 'POST',
                url: 'index.php',
                data: data,

                success: function(html) {
                alert('Сохранено');
                }
            });

            }
            </script>";

I know that what I've done is wrong anyway because I'm trying to connect 3 different types of JQuery. 我知道我所做的无论如何都是错误的,因为我正在尝试连接3种不同类型的JQuery。 SO that's why I'm here - to find out the proper way to to it correct. 所以这就是为什么我在这里-找出正确的方法来纠正它。 Thank you 谢谢

PS> I've looked through the search, but haven't found anything that suits my needs. PS>我已经仔细搜索过,但是没有找到适合我需求的内容。

You need to use jQuery.noConflict() if you are going to use multiple versions together. 如果要一起使用多个版本,则需要使用jQuery.noConflict()

See this question . 看到这个问题

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

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