Mootools 在最后一个元素之前插入新的元素

1. [代码]Sample    

<ul id="list"><li>1</li><li>2</li><li>3</li><li>4</li></ul>

2. [代码]script    

/** 假定已经加载Mootools代码 **/// 朝最后插入var el = new Element('list').set('html', 'Damn jQuery').inject($('list'));// 在list之前el.clone().appendText(', before it').inject($('list'), 'before');// 插入到list第一个元素el.clone().appendText(', in top').inject($('list'), 'top');// 插入到list最末一个元素el.clone().appendText(', in bottom').inject($('list'), 'bottom');// 围攻list最后一个元素var trueLast = $$('#list li').getLast();var el = new Element('li').set('html', 'Damn jQuery').inject(trueLast);el.clone().appendText(', before it').inject(trueLast, 'before');el.clone().appendText(', in top').inject(trueLast, 'top');el.clone().appendText(', in bottom').inject(trueLast, 'bottom');

有话要说