第一次使用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 中,它应该反射(reflect)文本区域内的内容,但根据 bbcode 进行格式化。
当我激活 jquery 1.11.3.min.js 的脚本时,它会崩溃或停止工作。
当 jquery 被注释掉时,导航不起作用,但 bbcode 工作完美......
关于为什么这样做有什么想法吗?
最佳答案
发生这种情况是因为您加载 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
关于jquery - 当我在页脚中添加在线 jquery 库时,bbcode 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34294658/