我有以下 div,其中有一个文本框。
<div id="DvPrint">
<div>
<input type="text" style="width: 100px;
margin-left: 25px;" class="textbox" id="ctl00_content_TxtLetterNumber" readonly="readonly" name="ctl00$content$TxtLetterNumber">
</div>
</div>
现在我使用 window.open 在新窗口中写入 div 内容。
n = window.open('M80Print.aspx', '_blank', 'status=no,toolbar=no,menubar=yes,height=550px,width=640px');
n.document.open();
n.document.write($('#DvPrint').html());
现在我想更改新打开的窗口中的文本框值。我该怎么做?? 像这样的事情:
n.document.getElementById('ctl00_content_TxtLetterNumber').innerHTML = "1";
但它不起作用。
最佳答案
n.document.getElementById('ctl00_content_TxtLetterNumber').value = "1";
更改文本框值是通过 value
完成的,而不是通过 innerHTML
完成的。
jQuery:
$('#ctl00_content_TxtLetterNumber', n.document).val('1');
关于javascript - 如何在新打开的窗口中设置文本框值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10571680/