mootools_一起使用jQuery和MooTools

mootools

There's yet another reason to master more than one JavaScript library: you can use some of them together! Since MooTools is prototype-based and jQuery is not, jQuery and MooTools may be used together on the same page.

掌握多个JavaScript库的另一个原因是:您可以将其中一些一起使用! 由于MooTools是基于原型的,而jQuery不是基于原型的,因此jQuery和MooTools可以在同一页面上一起使用。

XHTML和JavaScript (The XHTML and JavaScript)


<p>jQuery sets this paragraph's color to red but MooTools sets the border color.</p>
<script type="text/javascript" src="jquery-1.3.js"></script>
<script type="text/javascript">
	//no conflict jquery
	jQuery.noConflict();
	//jquery stuff
	(function($) {
		$('p').css('color','#ff0000');
	})(jQuery);
</script>
<script type="text/javascript" src="moo1.2.js"></script>
<script type="text/javascript">
	//moo stuff
	window.addEvent('domready',function() {
		$$('p').setStyle('border','1px solid #fc0');
	});
</script>


jQuery is namespaced so the $ function is free for MooTools to take hold of. The jQuery code passes jQuery to itself and then we call the argument $, thus jQuery is contained, so to speak.

jQuery具有命名空间,因此$功能免费供MooTools使用。 jQuery代码将jQuery传递给它自己,然后我们调用参数$ ,因此可以说包含了jQuery。

Obviously including two libraries within the same page is resource-consuming but if it's acceptable to the project and allows you to implement plugins from each library quickly, this may be a great option for you.

显然,在同一页面中包含两个库很耗资源,但是如果项目可以接受并允许您快速实现每个库中的插件,那么这对您来说是个不错的选择。

翻译自: https://davidwalsh.name/jquery-mootools

mootools

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值