尽管使用一种库是最好的解决方案(体积小,载入速度快,其实最好的还是手写javascript。),但有时候你不得不需要两种不同库的时候,你就可以参考以下方法了,适用于:jQuery和MooTools
- <!-- jquery gets the "$" method -->
- <script type="text/javascript" src="jquery-1.4.js" />
- <!-- mootools doesn't steal the "$" method; instead, document.id will be used -->
- <script type="text/javascript" src="mootools.js" />
- <!-- lets use them -->
- <script type="text/javascript">
- //with jquery, grab all links, make then red
- $('a').css('color','red');
- //with mootools, get the content div, set it's background color to pink
- document.id('content').setStyle('background','pink');
- //with mootools, get the content div, set it's background color to pink
- //this time, we'll give mootools the "$" method
- (function($) {
- $('content').setStyle('background','pink');
- })(document.id);
- </script>
MooTools’ Dollar 安全模式:http://mootools.net/blog/2009/06/22/the-dollar-safe-mode
相关日志

