js动态获取文本框的值

JavaScript010

js动态获取文本框的值,第1张

1.首先通过文本框的使用getelementbyid("idname");方法来获取文本框对象;

2.通过文本框对象来获取文本框的value值

在新打开的页面获得前面文本框内的内容:

window.opener.document.getelementbyid('文本框id').value

拓展资料:

根据指定的

id

属性值得到对象。返回

id

属性值等于

sid

的第一个对象的引用。假如对应的为一组对象,则返回该组对象中的第一个。

百度百科——getelementbyid

var textarea = document.createElement("textarea")

textarea.id="textarea"

document.body.appendChild(textarea)

var option = document.getElementsByTagName("select")[0]

option.onchange=function(){

option[option.selectedIndex].text=""

}

document.getElementsByTagName("select")[0].add(document.createElement("option"))