1
我知道我在做一些愚蠢的事情。但我無法弄清楚。我想在文檔加載時立即替換標籤內的一些文本。我知道該函數正在執行。但它在getElementById語句中被拒絕了,我不知道爲什麼。輸出應該說「新垃圾」。但是總是說「原創東西」。簡單的Javascript HTML替換
<html>
<script>
window.onload = filltip();
function filltip() {
alert('xyz');
var id = 'qourl';
var txt = 'New Junk';
//alert('current html=' + document.getElementById(id).innerHTML);
document.getElementById(id).innerHTML = '?<span class="classic">' + txt +
'</span>';
}
</script>
<body>
<a href='#' id='qourl'>Original Stuff</a>
</body>
</html>
非常感謝。這對我來說並沒有什麼意義,但是我嘗試了它並且很有效。 – Thread7 2013-03-05 17:18:27