星期六, 6月 18, 2011

無侵入腳本程式設計 unobtrusive scripting

意思即將html中的view(css),結構(html),行為(js)分開
不要把3者都摻在html裡
css就很明確的利用class name從html分離了
js見下例
//html夾了javascript
<a href="#" onclick="showPopuup('niceimage.jpg')">Nice image!</a>


將html與js分開
<a href="niceimage.jpg" id="nice">Nice image!</a>
document.getElementById('nice').onclick = function(){
showPopup(this.href)
};

沒有留言: