如何用JavaScript找到 用JavaScript动态添加的控件
用JavaScript在页面添加了一个按钮,可以再页面看到,
但是用JavaScript.getelementById找不到,
查看页面源代码也找不到
请问有什么找到的办法吗
谢谢
用JavaScript动态添加的控件查看页面源代码当然找不到到啦
用JavaScript.getelementById找不到的话你在用JavaScript动态添加的控件时有没有指定按钮的Id属性呢?
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title> </title>
<script type="text/javascript">
var i = 0;
function aa() {
i++;
txt = document.createElement("input");
txt.type = "text";
txt.id = "aa" + i;
txt.setAttribute("onclick", "aa()");
div1.appendChild(txt);
}
function Button2_onclick() {
var aaa = document.getElementById("aa2").value;
alert(aaa);
}
</script>
</head>
<body id="aaaa">
<form id=
相关问答:
后台有一个函数 protected string Fun1(int a, string b)
我想在javascript代码中调用它,怎么做?
function GridBind()
{
var a = 1;
var b='s';
& ......
后台:
protected void form_ini2(string id)
{
//处理代码
}
前台:
<script language="javascript">
function DbClickEvent(a ......
我的源文件如下:
<html>
<head> <title>show picture </title>
<script>
function change(fileName)
{
  ......
以下是一段JavsScript脚本,但运行时总会产生 “Microsoft JScript 运行时错误: 'null' 为空或不是对象”异常,大家帮看一下。
<form id="form1" runat="server">
< ......