<!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>div模拟textarea</title>
<link rel="stylesheet" href="../css/demo.css" type="text/css" />
<link rel="stylesheet" href="../css/hl.css" type="text/css" />
<style>
.test_box p {
margin:0;
}
.test_box {
width:400px;
min-height:120px;
_height:120px;
max-height:300px;
margin-left:auto;
margin-right:auto;
padding:3px;
outline:0;
border:1px solid #a0b3d6;
font-size:12px;
word-wrap:break-word;
overflow-x:hidden;
overflow-y:auto;
_overflow-y:visible;
}
.test_box a {
text-decoration:none;
color:#000;
}
.test_box:focus {
-moz-box-shadow:0 0 6px rgba(0, 100, 255, .45);
-webkit-box-shadow:0 0 6px rgba(0, 100, 255, .45);
box-shadow:0 0 6px rgba(0, 100, 255, .45);
border-color:#34538b;
}
</style>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function(){
$(".test_box").keyup(function(){$(this).html($(this).text())})
$(".aa").click(function(){alert($(".test_box").html())})
})
</script>
</head>
<body>
<div id="main">
<h1>div模拟textarea以实现高度自适应实例页面</h1>
<div id="body" class="light">
<div id="content" class="show">
<div class="demo">
<div id="testBox" class="test_box" contenteditable="true"> </div>
</div>
</div>
</div>
</div>
<input type="button" value="按钮" class="aa" />
</body>
</html>
div模拟textarea以实现高度自适应(去掉默认的@ mailto)
最新推荐文章于 2021-11-12 10:57:36 发布