[英]How to change an <input> field's VALUE attribute in real time with JavaScript?
[英]open the value of an input field in new tab. I would like to change the value of the input field in real time
我有一個輸入字段和一個按鈕。 輸入字段在加載時有一個值,但是我想在頁面加載后更改該值,然后在按鈕上單擊將其用作新選項卡中的url。 我是javascript新手,任何輸入都會有所幫助。 提前致謝。
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<input type="text" id="box" value="http://google.com" width="100%" />
</td>
<td>
<button id="newtab1" value = "Search" style="position: absolute;">New Tab</button>
</td>
</tr>
</table>
將onclick屬性添加到您的按鈕。
<button id="newtab1" value = "Search" style="position: absolute;" onclick="MyFunction();">New Tab</button>
然后輸入您的功能流程
<script>
function MyFunction(){
var url = document.getElementById('box').value
window.open(url);
}
</script>
document.onload=function(){
var url ="your url "
document.getElementById("box").value=url;
}
function myFunction(){
Window.open(document.getElementById("box");
}
<button id="newtab1" value = "Search" style="position: absolute;" onclick="myFunction();">New Tab</button>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.