J
jidixuelang
Hi,everyone!
Is there any way to change the "name" of one element?
Please look some simple code as following first:
It works fine!
But the following do not.
Is there any way to change the "name" of one element?
Please look some simple code as following first:
Code:
<form name="form1" method="post" action="">
<input type="text" id="spp" value="1" />
<input type="text" name="dlp" class="asd" readonly>
</form>
<script language="JavaScript">
document.getElementById("spp").id="a";
alert(document.getElementById("a").value);
</script>
It works fine!
But the following do not.
Code:
<form name="form1" method="post" action="">
<input type="text" id="spp" value="1" />
<input type="text" name="dlp" class="asd" readonly>
</form>
<script language="JavaScript">
document.getElementsByName("spp")[0].name = "a";
alert(document.getElementsByName("a")[0].value);
</script>