87,907
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html140/strict.dtd">
<html>
<head>
<title>Sample</title>
<script>
function test1(){
document.getElementById("MyTest").innerHTML=document.getElementById("userText").value;
}
</script>
</head>
<body>
<br>
<h1 id="MyTest" align="center">My Test String!<h1><br>
<form name="MyTestForm" id="MyTestForm">
<input type="button" value="左对齐" onclick="document.all['MyTest'].align='left'">
<input type="button" value="右对其" onclick="document.all['MyTest'].align='right'">
<input type="button" value="中间对齐" onclick="document.all['MyTest'].align='center'"><br>
<input type="button" value="字体红色" onclick="document.all['MyTest'].style.color='red'">
<input type="button" value="字体绿色" onclick="document.all['MyTest'].style.color='green'">
<input type="button" value="字体黑色" onclick="document.all['MyTest'].style.color='black'"><br>
<input type="text" name="用户内容" id="userText" size="30">
<input type="button" value="改变字符串内容"
onclick="test1()"><br>
</form>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html140/strict.dtd">
<html>
<head>
<title>Sample</title>
</head>
<body>
<br>
<h1 id="MyTest" align="center">My Test String!<h1><br>
<form name="MyTestForm" id="MyTestForm">
<input type="button" value="左对齐" onclick="document.all['MyTest'].align='left'">
<input type="button" value="右对其" onclick="document.all['MyTest'].align='right'">
<input type="button" value="中间对齐" onclick="document.all['MyTest'].align='center'"><br>
<input type="button" value="字体红色" onclick="document.all['MyTest'].style.color='red'">
<input type="button" value="字体绿色" onclick="document.all['MyTest'].style.color='green'">
<input type="button" value="字体黑色" onclick="document.all['MyTest'].style.color='black'"><br>
<input type="text" name="用户内容" id="userText" size="30">
<input type="button" value="改变字符串内容"
onclick="document.getElementById("MyTest").innerHTML=document.getElementById("userText").value"><br>
</form>
</body>
</html>
onclick="document.getElementById("MyTest").innerHTML=document.getElementById("userText").value"
onclick="document.getElementById('MyTest').innerHTML=document.getElementById('userText').value"