1
我要访问的aSubchapter
JavaScript文件中,我应该要做找到隐藏文件的代码动态创建的元素?(本页内容是页)如何通过使用JavaScript
.cs文件
protected void page_load()
{
HtmlGenericControl aSubchapter=new HtmlGenericControl("a");
aSubchapter.Attributes.Add("href","somevalue");
aSubchapter.ID="subchapter";
}
在.aspx文件
<script type="text/javascript">
var subchap=document.getElementById('<%=subchapter.ClientID%>');
//(The above lines says that subchap is undefined)
</script>
尝试使用'的document.getElementById(“小节”)''因为'是不是服务器控件 –
甚至我试过,但它说不确定 –
并控制被页面呈现?尝试执行你的代码后加载'document.onload = function(){/ *运行代码在这里* /}' –