<script type="text/javascript" src="jquery-1.js"></script>
<script type="text/javascript" src="mootools.js"></script>
<script type="text/javascript" src="slideshow.js"></script>
<script type="text/javascript">
//<![CDATA[
window.addEvent('domready', function(){
var data = {
'1.jpg': { caption: 'Volcano Asención in Ometepe, Nicaragua.' },
'2.jpg': { caption: 'A Ceibu tree.' },
'3.jpg': { caption: 'The view from Volcano Maderas.' },
'4.jpg': { caption: 'Beer and ice cream.' }
};
var myShow = new Slideshow('show', data, {controller: true, height: 400, hu: 'images/', thumbnails: true, width: 500});
});
//]]>
</script>
<script type="text/javascript">
$(document).ready(function()
{
//slides the element with class "menu_body" when paragraph with class "menu_head" is clicked
$("#firstpane p.menu_head").click(function()
{
$(this).css({backgroundImage:"url(down.png)"}).next("div.menu_body").slideToggle(300).siblings("div.menu_body").slideUp("slow");
$(this).siblings().css({backgroundImage:"url(left.png)"});
});
//slides the element with class "menu_body" when mouse is over the paragraph
$("#secondpane p.menu_head").mouseover(function()
{
$(this).css({backgroundImage:"url(down.png)"}).next("div.menu_body").slideDown(500).siblings("div.menu_body").slideUp("slow");
$(this).siblings().css({backgroundImage:"url(left.png)"});
});
});
</script>
<!--[if lt IE 7]>
<script type="text/javascript" src="unitpngfix.js"></script>
<![endif]-->
-2
A
回答
2
在包含jQuery之後,您應該調用$ .noConflict()。這將刪除從全局命名空間中的「$」:
<script type="text/javascript" src="jquery-1.js"></script>
<script>
$.noConflict();
</script>
<script type="text/javascript" src="mootools.js"></script>
在這一點上,你應該使用jQuery的代替的$,如果你想調用jQuery代碼。或者你可以通過在封閉包裹$符號使用招:
<script type="text/javascript">
jQuery(function($) {
// here you can use $ instead of jQuery
});
</script>
3
jQuery的無衝突是一個不錯的選擇。我建議儘管做這樣的事情:
<script language=javascript>
var $j = jQuery.noConflict();
</script>
這將讓您訪問jQuery的功能使用$ j代替$。我使用這種方法通過GreaseMonkey在大多數頁面中包含jQuery。我有一個jQuery的自定義副本,最後包含上面的調用。我使用GreaseMonkey將一個指向該腳本的鏈接插入到網頁頭部,以便我可以使用$ j調查對象屬性,而不會影響頁面中可能存在的其他庫並使用$。
相關問題
- 1. 衝突的腳本
- 2. 腳本衝突
- 3. 頁眉和頁腳衝突
- 4. 衝突腳本的WordPress
- 5. 衝突的JQuery腳本
- 6. jQuery的腳本衝突
- 7. JQuery腳本衝突
- 8. Sitefinity腳本衝突
- 9. jQuery腳本衝突
- 10. Magento主頁只在index.php上有衝突
- 11. 衝突的CSS頁眉/頁腳
- 12. 粘性頁腳衝突css
- 13. 我想通過腳本推遲衝突
- 14. 2個ValidateRequiredFields腳本在2個頁面上發生衝突
- 15. 兩個jQuery腳本在同一頁上發生衝突
- 16. 小腳本創建衝突
- 17. 與腳本和prototype.js衝突
- 18. 兩個jQuery腳本衝突
- 19. SystemJS腳本打字衝突
- 20. jQuery/Ajax .....腳本衝突processResults
- 21. jquery菜單腳本衝突
- 22. the_post()衝突在WordPress腳本
- 23. lightbox2與腳本衝突
- 24. 多個jQuery腳本衝突
- 25. 手風琴腳本衝突
- 26. 多個腳本衝突
- 27. 2 jQuery腳本衝突
- 28. SVN鉤子腳本衝突
- 29. jQuery腳本標籤衝突
- 30. 腳本代碼衝突
那麼究竟是什麼問題呢?什麼樣的衝突? – Marc 2010-06-03 21:03:37