对我个人感兴趣的

想看看有什么有趣的

Valid XHTML 1.0 Transitional Valid CSS!

本站测试通过:Ie6,Ie7,Ie8,Firefox,Safari,Chrome,遨游。
为达到最佳效果,请使用IE6以上的浏览器版本

快速导航

在网页上同时使用jQuery和 MooTools的解决方法

尽管使用一种库是最好的解决方案(体积小,载入速度快,其实最好的还是手写javascript。),但有时候你不得不需要两种不同库的时候,你就可以参考以下方法了,适用于:jQuery和MooTools

  1. <!-- jquery gets the "$" method -->
  2. <script type="text/javascript" src="jquery-1.4.js" />
  3. <!-- mootools doesn't steal the "$" method; instead, document.id will be used -->
  4. <script type="text/javascript" src="mootools.js" /> 
  5. <!-- lets use them -->
  6. <script type="text/javascript">
  7. //with jquery, grab all links, make then red
  8. $('a').css('color','red');
  9. //with mootools, get the content div, set it's background color to pink
  10. document.id('content').setStyle('background','pink');
  11. //with mootools, get the content div, set it's background color to pink
  12. //this time, we'll give mootools the "$" method
  13. (function($) {
  14.     $('content').setStyle('background','pink');
  15. })(document.id);
  16. </script>

MooTools’ Dollar 安全模式:http://mootools.net/blog/2009/06/22/the-dollar-safe-mode

相关日志

收藏&分享

留下回复