歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> jQuery插件placeholder的使用方法

jQuery插件placeholder的使用方法

日期:2017/3/1 9:40:54   编辑:Linux編程

今天有空演示一下jQuery插件placeholder的使用方法,借助該插件可以輕松實現HTML5中placeholder特效:

效果圖:

實現代碼:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>借助jQuery placeholder實現HTML5中placeholder特效</title>
<script type="text/javascript" src="<%=basePath%>js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/jquery.placeholder.js"></script>
<script type="text/javascript">
$(function() {
$('input, textarea').placeholder();
});
</script>
<style type="text/css">
input, textarea { font-family: Helvetica, Arial; color: #000;}
.placeholder {color: #aaa;}
</style>
</head>

<body>
<center ><font >借助jQuery placeholder實現HTML5中placeholder特效</font></center><br><br>
<center><font >Linux公社 www.Linuxidc.com</font></center><br><br>
<input type="text" id="userName" name="userName" placeholder="請輸入用戶名…" ><br>
<input type="password" id="password" name="password" placeholder="請輸入密碼…" ><br>
<textarea id="personalInformation" name="personalInformation" rows="3" cols="50" maxlength="200" placeholder="請輸入個人信息…"></textarea>
</body>
</html>

說明:上面例子並不是HTML5頁面,但由於使用了該插件所以看上去和HTML5的效果差不多;上面例子使用了jquery-1.8.3.min.js和jquery.placeholder.js兩個文件,這兩個文件可在下面的下載資源中找到。

------------------------------------------分割線------------------------------------------

免費下載地址在 http://linux.linuxidc.com/

用戶名與密碼都是www.linuxidc.com

具體下載目錄在 /2014年資料/8月/12日/jQuery插件placeholder的使用方法/

下載方法見 http://www.linuxidc.com/Linux/2013-07/87684.htm

------------------------------------------分割線------------------------------------------

jQuery權威指南 PDF版中文+配套源代碼 http://www.linuxidc.com/Linux/2013-10/91059.htm

jQuery實戰 中文PDF+源碼 http://www.linuxidc.com/Linux/2013-09/90631.htm

《jQuery即學即用(雙色)》 PDF+源代碼 http://www.linuxidc.com/Linux/2013-09/90383.htm

鋒利的jQuery(第2版) 完整版PDF+源碼 http://www.linuxidc.com/Linux/2013-10/91527.htm

jQuery完成帶復選框的表格行高亮顯示 http://www.linuxidc.com/Linux/2013-08/89406.htm

jQuery基礎教程(第4版) PDF 完整高清版+配套源碼 http://www.linuxidc.com/Linux/2014-03/98162.htm

--------------------------------------分割線 --------------------------------------

jQuery 的詳細介紹:請點這裡
jQuery 的下載地址:請點這裡

Copyright © Linux教程網 All Rights Reserved