这是 html 代码:
<table align='right' >
<tr>
<td><asp:Label ID="lblEmail" runat="server" Text=""></asp:Label></td>
<td > <div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark">
</div></td>
</tr>
</table>
这是我的函数脚本:
<script>
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
document.getElementById('lblEmail').InnerHTML = profile.getEmail();
// alert(profile.getEmail());
};
</script>
lblEmail
无法显示值,为什么?
我尝试使用警报,它显示电子邮件正常。
最佳答案
输入带有小写 i 的innerHTML:
<script>
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
document.getElementById('lblEmail').innerHTML = profile.getEmail();
// alert(profile.getEmail());
};
</script>
关于javascript - 为什么不能从 javascript 更改 asp.net 中的标签文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44197618/