讓 jQuery 與 MooTools 並存


/ Published in: JavaScript
Save to your folder(s)

from [here](http://net.tutsplus.com/tutorials/javascript-ajax/make-your-mootools-code-shorter-faster-and-stronger/ "")


Copy this code and paste it in your HTML
  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>

URL: http://net.tutsplus.com/tutorials/javascript-ajax/make-your-mootools-code-shorter-faster-and-stronger/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.