kourge 寫:
caucAll( document.getElementsByClassName('dices') , document.getElementsByClassName('view') , document.getElementsByClassName('sumary') , $('total') );
以上可以寫成:
caucAll( $$('.dices'), $$('.view'), $$('.sumary'), $('total') );
以下:
function init() {
if( location.pathname.search(/^\/(index\.html)?$/) >= 0 ) {
for(var i=0 ; i < document.getElementsByClassName('stealth').length ; i++) {
document.getElementsByClassName('stealth')[i].style['display']='none';
document.getElementsByClassName('detect')[i].innerHTML='<a title="展開隱藏區塊" onClick=" document.getElementsByClassName(\'stealth\')['+i+'].style[\'display\']=\'block\'; this.style.display=\'none\'; ">(繼續閱讀)</a>';
}
}
}
可以改成:
function init() {
if( location.pathname.search(/^\/(index\.html)?$/) >= 0 ) {
$$('stealth').each(function(element, index) { element.hide();
$$('.detect')[index].update('<a title="展開隱藏區塊" onClick=" $$(\'.stealth\')['+i+'].show(); $(this).hide(); ">(繼續閱讀)</a>');
}
}
}
反正...
document.getElementByClassName('blah') -> $$('.blah')
for 迴圈 ->.each()
element.innerHTML = 'blah' -> element.update('blah')
new Array(1, 2, 3) -> [1, 2, 3]
Opera 的錯誤是 unknown thread?
喔喔
原來還有這招,受教了
之前雖然有去翻過API
不過好像都沒抓到要領
至於Opera的錯誤,是的
用Firefox也會有一些警告出現在prototype.js裡
有可能是我傳了不嚴謹的物件
但是我找不出來= =