我在想,如果我能避免我的HTML插入<script>
代碼,並使用事件,而不是:的Javascript事件定義
<div id="foo">
<script>
document.getElementById('foo').className = 'has-js';
// ^^ can I put this in some on* attribute of #foo,
// and make it run at this point ?
</script>
...
<div ...
有一些on*
屬性我可以在#foo
DIV用在哪裏可以插入我的JavaScript?
你最終想達到什麼目的? – 2013-03-03 14:43:35
初始加載時有一個事件(不在IE上,但jQuery可以模擬它)。 – 2013-03-03 14:43:43
@lee,儘快調整'#foo' div的類 – Alex 2013-03-03 14:44:10