MooTools a compact javascript framework
http://mootools.net/docs/core
30天学会 MooTools 教学(1): 认识MooTools
http://www.cnblogs.com/see7di/archive/2011/11/10/2244844.html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div id="box1" class="box box1">box1</div>
<div id="box2" class="box box2">box2</div>
<script src="mootools-core-1.4.5-full-nocompat.js"></script>
<script>
/*
* domready
*/
window.addEvent('domready', function() {
console.log('domready')
}) /*
* $chk 最新版本已不支持
* 检查一个值是不是已经定义或者已经赋值,undefined或者null时返回false(←描述有问题)
*/
var $chk = function(obj) {
return !!(obj || obj === 0)
}
var a = 2
console.log($chk(a))
console.log(!!2, !!(undefined===0), 2, undefined===0) /*
* Number.random
*/
console.log(Number.random(5, 20)); // 默认ID?
$('box1').addEvent('click', function() {
alert(2)
}) /*
* rgbToHex
* 把rgb转换为十六进制(HEX)
*/
console.log([255, 255, 255].rgbToHex(), [255, 255, 255].rgbToHex(true), [255, 255, 255, 0].rgbToHex()) /*
* round
* 对小数取整
*/
console.log((12.45).round(), (12.45).round(1), (12.45).round(-1)) /*
* getLast
* 得到数组中的最后一个元素
*/
console.log([1, 2, 3].getLast()) /*
* each
* 对数组中的每个元素执行一段脚本
*/
Array.each(['Sun', 'Mon', 'Tue'], function(day, index) {
console.log('name: ' + day + ', index: ' + index)
}) /*
* periodical
* 每隔多少毫秒执行
*/
var count = 0
function myFunction() {
console.log(count);
if (++count > 10) {
clearInterval(timer)
}
}
var timer = myFunction.periodical(1000)
</script>
</body>
</html>