mootools 2
.get();
$('id_name').get('tag');
.set();
// 这将设置id为id_name的元素链接地址为“http://www.google.com”
$('id_name').set('href', 'http://www.google.com');
.erase();
// 这讲移除id为id_name的元素的href属性
$('id_name').erase('href');
.inject();
elementC.inject(elementB, 'before'); //底部bottom,顶部top,在某个元素的前面before,在某个元素的后面after
#新元素插入
var newDiv = function() {
var bodyWrapVar = $('newElementContainer');
var idValue = $('id_input').get('value');
var textValue = $('text_input').get('value');
var newElementVar = new Element('div', {
'id': idValue,
'text': textValue
});
// 下面这句是说:“把newElementVar插入到bodyWrapVar的内部顶部”
newElementVar.inject(bodyWrapVar, 'top');
};
.setStyle();
$('body_wrap').setStyle('background-color', '#eeeeee');
$$('.class_name').setStyle('background-color', '#eeeeee');
.getStyle();
var styleValue = $('body_wrap').getStyle('background-color');
var bodyStyles = $('body_wrap').getStyles('width', 'height', 'background-color');
toInt()
$type()
.limit()//number.limit(0, 255)
.trim()//trim函数提供了一个简单直接的方式来去掉任何你想处理的字符串两端的空白字符。
.clean().contains()//注意:字符串、过滤词组
//把我们要禁止的词放进一个数组
var banned_words = ['drat', 'goshdarn', 'fiddlesticks', 'kumquat'];
// 获得文本域中的内容
var textarea_input = $('textarea_1').get('value');
if (textarea_input.contains(banned_word)){
alert(banned_word + ' is not allowed');
};
.substitute()
// 建立要替换的字符串
var text_for_substitute = "{substitute_key} and the original text";
// 把要替换的对象作为参数传给substitute方法
var result_text = text_for_substitute.substitute({substitute_key : 'substitute_value'});
// result_text现在就是"substitute_value and the original text"

浙公网安备 33010602011771号