jQuery實現(xiàn)輸入框的放大和縮小功能示例
本文實例講述了jQuery實現(xiàn)輸入框的放大和縮小功能。分享給大家供大家參考,具體如下:
<%@ page language="java" import="java.util.*"pageEncoding="UTF-8"%>
<%
Stringpath = request.getContextPath();
StringbasePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>" rel="external nofollow" >
<title>My JSP 'index4.jsp' startingpage</title>
<meta http-equiv="pragma"content="no-cache">
<meta http-equiv="cache-control"content="no-cache">
<meta http-equiv="expires"content="0">
<meta http-equiv="keywords"content="keyword1,keyword2,keyword3">
<meta http-equiv="description"content="This is my page">
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>
<input type="text"id="content">
<label><input type="button"name="Submit" value="放大" id="bigger"/></label>
<label><input type="button"name="Submit2" value="縮小" id="small"/></label>
<script type="text/javascript">
$(function(){
var content=$("#content");
$("#bigger").click(function(){
if(content.height()<500){
content.height(content.height()+50);
}
else{
alert("已經(jīng)夠高了");
}
});
$("#small").click(function(){
if(content.height()>50){
content.height(content.height()-50);
}
else{
alert("無法在縮小了");
}
});
});
</script>
</body>
</html>
運(yùn)行效果如下:

感興趣的朋友可以使用在線HTML/CSS/JavaScript代碼運(yùn)行工具http://tools.jb51.net/code/HtmlJsRun測試一下運(yùn)行效果。
更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery頁面元素操作技巧匯總》、《jQuery常見事件用法與技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常見經(jīng)典特效匯總》及《jquery選擇器用法總結(jié)》
希望本文所述對大家jQuery程序設(shè)計有所幫助。
- jquery實現(xiàn)input輸入框?qū)崟r輸入觸發(fā)事件代碼
- js與jquery實時監(jiān)聽輸入框值的oninput與onpropertychange方法
- input 輸入框獲得/失去焦點時隱藏/顯示文字(jquery版)
- jquery清空textarea等輸入框?qū)崿F(xiàn)代碼
- 基于jQuery的input輸入框下拉提示層(自動郵箱后綴名)
- jQuery實現(xiàn)動態(tài)添加、刪除按鈕及input輸入框的方法
- jquery實現(xiàn)textarea輸入框限制字?jǐn)?shù)的方法
- Jquery動態(tài)添加輸入框的方法
- jQuery表單獲取和失去焦點輸入框提示效果的實例代碼
- 基于jquery實現(xiàn)一張圖片點擊鼠標(biāo)放大再點縮小
- jQuery div層的放大與縮小簡單實現(xiàn)代碼
相關(guān)文章
Jquery ajax不能解析json對象,報Invalid JSON錯誤的原因和解決方法
我們知道Invalid JSON錯誤導(dǎo)致的json對象不能解析,一般都是服務(wù)器返回的json字符串的語法有錯誤。這種情況下,我們只需要仔細(xì)的檢查一下json就可以解決問題。2010-03-03
jQuery刪除節(jié)點的三個方法即remove()detach()和empty()
jQuery提供了三種刪除節(jié)點的方法,即remove(),detach()和empty(),下面為大家詳細(xì)介紹下jQuery刪除節(jié)點三個方法的具體使用2013-12-12
Jquery each方法跳出循環(huán),并獲取返回值(實例講解)
這篇文章主要是對Jquery each方法跳出循環(huán),并獲取返回值進(jìn)行了詳細(xì)的介紹,需要的朋友可以過來參考下,希望對大家有所幫助2013-12-12

