我試圖在下面使用Javascript添加一段文本的鏈接。請幫忙。範圍內的JavaScript鏈接
<div id="features">
<h2>Features</h2>
<div id="emma2011_left">
<h2>Image of the Day</h2>
<div id="dImg">
<div id="dailyimg" class="feature"></div>
<div id="title" class="feature"></div>
<div id="caption" class="feature"></div><br />
<span id="span" class="feature"><a id="pidlink">Link to the object</a></span>
</div>
</div>
<script type="text/javascript">
...
link = document.createElement("a");
link.setAttribute("href", "http://abc.org/index.aspx?objectid=" + oTodayImage.pid);
var span = document.createElement("span");
var txt = link.href;
var textNode = document.createTextNode(txt);
span.appendChild(textNode);
</script>
所以什麼錯? –
鏈接沒有顯示,我不知道我在做什麼錯 – multiv123
那是因爲你永遠不會追加任何鏈接。 –