基本信息
源码名称:Jquery 实现textarea placeholder 多行效果
源码大小:1.41KB
文件格式:.html
开发语言:js
更新时间:2016-03-22
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no" name="viewport" id="viewport" />
<title>提交结果</title>
<meta name="keywords" content="">
<meta name="description" content="">
<style type="text/css">
textarea{
width:300px;
height:100px;
color:gray;
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.js"></script>
<script type="text/javascript">
$(function () {
try {
var placeholder = '请填写\n完成任务的序号:\n手机号码:\n以便客服给您发放福利';
$('textarea').attr('value', placeholder);
$('textarea').focus(function () {
if ($(this).val() === placeholder) {
$(this).attr('value', '');
}
});
$('textarea').blur(function () {
if ($(this).val() === '') {
$(this).attr('value', placeholder);
}
});
} catch (ex) {
alert(ex.message);
}
});
</script>
</head>
<body>
<textarea class="message" name="u_massage"></textarea>
</body>
</html>