非哥 如何用js修改一个元素的id ? dc.id = 'bbc';wrong 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $("#objID").attr("id","你要改的id"); <input type='text' id="a"><input type='button' onclick="document.all('a').id='b'">按钮只能按一次,而且text的ID改变后在源文件里是看不出来的,但是你再次点击按钮的时候,就显示没有那个a的对象了 document.getElemettByID("objID").id="你要的ID"; <html><body><div id="a"></div></body><script type="text/javascript" language="javascript">document.getElementById("a").id="b";alert(document.getElementById("b").id);</script></html>在我这边测试是成功的 document.getElementById("aaa").id="ID";这样是可以的~~ <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="CaiPiao.WebForm2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title></title> <script type="text/javascript"> function btnClick() { document.getElementById("txt").id = "tt"; alert(document.getElementById("tt").value);//测试一下是否能够找到新修改ID之后的Textbox值。 } </script></head><body> <form id="form1" runat="server"> <div> <input id="txt" type="text" /> <input type=button value="修改文本框ID" onclick="btnClick()" /> </div> </form></body></html> 顶JQUERY用着舒服。目前才接触不久,哎,继续修炼去 passwordRecovery使用 已经声明长度的数组,长度还可以变 吗? 上传图片时单击选中图片IE8显示不了图片 用户控件里可以使用ajax吗? 关于com+的问题! ext3.3 调用问题 存储过程返回参数一般有什么用? 急问:关于ASP中关闭窗体事件的问题 求高手帮助:打印PDF文件的问题 asp.net的运行环境要求 什么样的情况会触发session_end事件 asp.net如何读取客户端的文件
<input type='button' onclick="document.all('a').id='b'">
按钮只能按一次,而且text的ID改变后在源文件里是看不出来的,但是你再次点击按钮的时候,就显示没有那个a的对象了
<body>
<div id="a"></div>
</body>
<script type="text/javascript" language="javascript">
document.getElementById("a").id="b";
alert(document.getElementById("b").id);
</script>
</html>在我这边测试是成功的
document.getElementById("aaa").id="ID";这样是可以的~~
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="CaiPiao.WebForm2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script type="text/javascript">
function btnClick() {
document.getElementById("txt").id = "tt";
alert(document.getElementById("tt").value);//测试一下是否能够找到新修改ID之后的Textbox值。
}
</script>
</head><body>
<form id="form1" runat="server">
<div>
<input id="txt" type="text" />
<input type=button value="修改文本框ID" onclick="btnClick()" />
</div>
</form>
</body>
</html>