JavaScript练习题目(2)文本域内的字符串反转

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>My First Script</title>
<script type="text/javascript">
function test() {
	var text_string = document.getElementById("input_text").value;
	var result = text_string.split("").reverse().join("");
	document.getElementById("result").innerHTML = result;
}
</script>
</head>
<body>
<form>
	<label>输入</label><input id="input_text" type="text" value="默认值" />
	<input type="button" value="设置为'哈哈'" onclick="test();" />
	<div id="result"></div>
</form>
</body>
</html>


原文链接: http://blog.csdn.net/poechant/article/details/6975229

你可能感兴趣的:(JavaScript练习题目(2)文本域内的字符串反转)