2

我正在开发 C#.net 项目,我为菜单和图像滑块等使用了多个 javascript 库,但是出现了冲突,我该如何避免这种情况?

4

1 回答 1

1

在加载 jQuery 库之后立即调用$.noConflict(); 然后您对 jQuery 的所有调用都是使用jQuery关键字进行的。来自jQuery 网站的示例:

<script type="text/javascript" src="other_lib.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
  $.noConflict();
  jQuery(document).ready(function($) {
    // Code that uses jQuery's $ can follow here.
  });
  // Code that uses other library's $ can follow here.
</script>
于 2013-03-13T11:13:52.043 回答