gpt4 book ai didi

javascript 无法读取 null 的属性 'style'

转载 作者:行者123 更新时间:2023-12-02 16:11:03 25 4
gpt4 key购买 nike

 function showNotes() {

var ThemeValues = "<%=str3%>"
if (ThemeValues.value == "MyCity-Social") {

document.getElementById("TextBox1").style.visibility = "visible";
document.getElementById("TextBox2").style.visibility = "visible";
$.blockUI({
message: $('#divNotes'),
css: {}
});
} else {

//ERROR
document.getElementById("TextBox1").style.display = "none";
document.getElementById("TextBox2").style.display = "none";

$.blockUI({
message: $('#divNotes'),
css: {}
});

}
}

函数在顶部声明并在单击时调用,但错误如上所述,并且 var ThemeValues 不显示值

最佳答案

在文本框控件上添加 ClientIDMode="Static"

<asp:TextBox ID="TextBox1" runat="server" Width="385px" Height="50px" TextMode="MultiLine" ClientIDMode="Static"></asp:TextBox>

然后上面的代码就可以工作了。

对于 ThemeValues 变量,您不会在那里获得任何控制值,因为您只为那里的变量分配一个字符串。

用这个代替

var ThemeValues = document.document.getElementById("<%=str3%>");

关于javascript 无法读取 null 的属性 'style',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30206224/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com