調用從HTML一個javascript我有以下的頁腳的HTML代碼如何使用ID
<footer class="footer">
<div class="container">
<p class="text-muted"> <a href="about.html">About Us</a> | <a href="contactus.html">Contact Us</a></p>
<p class="text-muted">© Copyright of abc
<span id="yearfooter"> </span>
</p>
</div>
</footer>
<script src="scripts/abc.js"></script>
和我的JScript以下
$(function() {
$('#yearfooter').footer({
document.write(new Date().getFullYear());
});
});
我很新的javascript。我試圖讓這個腳本動態獲取當前年份並在頁腳中顯示。但是,憑藉這一點,我似乎根本看不到年份。我不確定我在這裏做錯了什麼。
'$( '#yearfooter')標記這個問題與jQuery文本((新的Date())。 getFullYear())' – adeneo
@Michelle你的jQuery語法不正確,使用'document.write()'可能會影響性能。 – Raptor
由於您在dom準備好之後調用'document.write()',它會替換文檔中的所有內容 –