我是一个初学者。我想要弹出一个警告框,其中包含一个 <div>
的文本内容,但是得到了 null
。
Javascript:
alert(document.getElementById("ticker").value);
HTML
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<script src="Tick.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div id="ticker">
Sample
</div>
</asp:Content >
我做错了什么?
Element.innerText
,在其他地方查看Element.textContent
。 - user1385191