<?xml version="1.0" encoding="UTF-8" ?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
<script type="text/javascript">
document.getElementById("text").value = "Hello";
</script>
</head>
<body>
<textarea rows="10" cols="80" id="text"></textarea>
</body>
</html>但是这样写压根没有修改textarea的内容,求教高手应该怎么改
解决方案 »
- 你可能不知道的10个JavaScript小技巧 作者:梦想
- 想通过js自动提交表单,但是却不执行Onsubmit的事件,怎么办?
- 正则表达式 验证邮箱或手机号码
- 想从事网页编程选择什么语言?
- Repeater嵌套Repeater js实现单选问题
- 一个超难的checkbox问题?
- 请问用JAVASCRIPT怎样让主机喇叭发生,调用如beep()函数的功能
- 我有一个连接.想点击的同时刷新两个页面,怎么实现?
- 我的页面有上下两桢,上面一桢为javascript代码的下拉菜单,但在IE5中被下面的桢挡住了,请问有什么方法解决?
- “拒绝访问”问题
- 获取form中button的值
- 求教$("#mainForm")[0].submit()的用法
<textarea rows="10" cols="80" id="text"></textarea>
<script type="text/javascript">
document.getElementById("text").value = "Hello";
</script>写在后边,或者<!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" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>test</title>
<script type="text/javascript">
window.onload = function(){
document.getElementById("text").value = "Hello";
}
</script>
</head>
<body>
<textarea rows="10" cols="80" id="text"></textarea>
</body>
</html>等页面的dom结构加载完之后js才能 document.getElementById("text") 获得对象。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title> </head>
<body>
<textarea rows="10" cols="80" id="text"></textarea>
<script type="text/javascript">
document.getElementById("text").value = "Hello";
</script>
</body>
</html>