我不能将Javascript代码与Bootstrap模板一起使用 [英] i can't use javascript code with bootstrap template

查看:122
本文介绍了我不能将Javascript代码与Bootstrap模板一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在struts2应用程序中使用了一些Bootstrap模板:

I use some Bootstrap template with my struts2 applicaion :

http://www.bootstrapzero.com/bootstrap-template/adminlte

:

https://github.com/almasaeed2010/AdminLTE/tree/master/js/AdminLTE

我想将一些JavaScript代码集成到我的jsp页面中:

I want to integrate some javascript code to my jsp page :

<script>
$(document).ready(function(){

//javascript code     
    });

</script>

新代码不适用于以下文件:

the new code does not work with the use of these files:

 <!-- AdminLTE App -->
        <script src="<c:url value="page/js/AdminLTE/app.js"/>" type="text/javascript"></script>

        <!-- AdminLTE dashboard demo (This is only for demo purposes) -->
        <script src="<c:url value="page/js/AdminLTE/dashboard.js"/>" type="text/javascript"></script>

但是,如果我未在代码中调用脚本,则脚本可以正常工作;我该如何解决这个问题!

However the script works fine if I not call them in my code; how can i resolve this problem please !

推荐答案

这可能是jQuery冲突.尝试像这样在jQuery中使用noConflict:

This might be a jQuery conflict. Try using the noConflict in jQuery like this:

var $j = jQuery.noConflict();

然后您的脚本将如下所示:

Then your script will look like this:

<script>
var $j = jQuery.noConflict();    

$j(document).ready(function(){

//javascript code     
});

</script>

希望这会有所帮助!

这篇关于我不能将Javascript代码与Bootstrap模板一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆