当我在页脚中添加在线jquery库时,bbcode不起作用

时间:2015-12-15 16:38:55

标签: jquery twitter-bootstrap bbcode

第一次使用stackoverflow ..很遗憾在这里感到困惑。

我刚刚在我的bootstrap网页上实现了bbcode。 它一切正常,因为我也想要它,但是当它工作时,我的导航不起作用。

当我添加此内容时

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>

到我的页脚,我的导航工作正常,但然后我的bbcode无法正常工作。

如果我发表评论,脚本标签。 bb代码工作正常,但我的导航不起作用...

这是我使用的BBcode:

<div class="addChatMessage">

<form action="../code/crud.php?action=addToChat" method="POST" class="form-inline">

<div class="form-group">
   <textarea id="test" name="message" class="form-control"></textarea>                                      
</div>
<button type="submit" class="btn btn-success">Send</button>
</form>

<!-- preview bbcode-->

<br><H5 class="white">Preview</H5>

<div id="preview" class="previewbox col-12"></div>



<!-- load ajax library-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>

<!-- load custom js -->

<script src='bbedit/jquery.bbcode.js' type='text/javascript'></script>


<script type="text/javascript">

$(document).ready(function(){
                  $("#test").bbcode({tag_bold:true,tag_italic:true,tag_underline:true,tag_link:true,tag_image:true,button_image:true});
                  process();
            });

            var bbcode="";
            function process()
            {
                if (bbcode != $("#test").val())
                {
                        bbcode = $("#test").val();
                        $.get('bbedit/bbParser.php',
                        {
                                bbcode: bbcode
                        },
                        function(txt){
                                $("#preview").html(txt);
                                })

                }
                setTimeout("process()", 2000);

            }



        </script>
在预览bbcode中,它应该反映textarea内部的内容,但是根据bbcode进行格式化。

当我激活jquery 1.11.3.min.js的脚本时,它会崩溃或停止工作。

当jquery被注释掉时,导航无效,但bbcode工作正常......

关于它为什么会这样做的任何想法?

2 个答案:

答案 0 :(得分:0)

这是因为你加载了jquery两次,一次在你的页脚(jquery 1.11)中,一次在代码中

<!-- load ajax library-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>

我建议你删除上面的代码,只在你的bbcode上面添加适当的jquery版本。检查bbcode是否与jquery 1.11一起使用,或者使用jquery 1.3.2

进行导航

答案 1 :(得分:0)

我遇到了这个问题。 问题是您使用了两个不同的jQuery库,因此彼此之间有conflict个库。要删除此问题,您必须使用jQuery.noConflict(); 所以你的代码就是这样的。试试这个让我知道,我也有其他想法。

    <div class="addChatMessage">

<form action="../code/crud.php?action=addToChat" method="POST" class="form-inline">

<div class="form-group">
   <textarea id="test" name="message" class="form-control"></textarea>                                      
</div>
<button type="submit" class="btn btn-success">Send</button>
</form>

<!-- preview bbcode-->

<br><H5 class="white">Preview</H5>

<div id="preview" class="previewbox col-12"></div>



<!-- load ajax library-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>

<!-- load custom js -->
<script type="text/javascript">
      var $ = jQuery.noConflict();
</script>
<script src='bbedit/jquery.bbcode.js' type='text/javascript'></script>


<script type="text/javascript">

$(document).ready(function(){
                  $("#test").bbcode({tag_bold:true,tag_italic:true,tag_underline:true,tag_link:true,tag_image:true,button_image:true});
                  process();
            });

            var bbcode="";
            function process()
            {
                if (bbcode != $("#test").val())
                {
                        bbcode = $("#test").val();
                        $.get('bbedit/bbParser.php',
                        {
                                bbcode: bbcode
                        },
                        function(txt){
                                $("#preview").html(txt);
                                })

                }
                setTimeout("process()", 2000);

            }



        </script>
相关问题