jQuery中Form相關(guān)知識(shí)匯總
form中的單行文本獲取和失去焦點(diǎn)
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<script type="text/javascript" src="../../js/jquery-2.1.3.js"></script>
<title></title>
<style type="text/css">
input:focus, textarea:focus {
border: 1px solid#f00;
background: #fcc;
}
.focus {
border: 1px solid#f00;
background: #fcc;
}
</style>
</head>
<body>
<form action="#" method="post" id="regForm">
<fieldset>
<legend>個(gè)人基本信息</legend>
<div>
<label for="username">名稱:</label>
<input id="username" type="text">
</div>
<div>
<label for="pass">密碼:</label>
<input id="pass" type="password">
</div>
<div>
<label for="msg">詳細(xì)信息:</label>
<textarea id="msg"></textarea>
</div>
</fieldset>
</form>
</body>
<script type="text/javascript">
/**
* 1.單行文本框---得到焦點(diǎn)和失去焦點(diǎn)
* */
$(function () {
$(":input").focus(function () {
$(this).addClass("focus");
}).blur(function () {
$(this).removeClass("focus");
})
})
</script>
</html>
更改多行文本的高度
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<script type="text/javascript" src="../../js/jquery-2.1.3.js"></script>
<title></title>
<style type="text/css">
* { margin:0; padding:0;font:normal 12px/17px Arial; }
.msg {width:300px; margin:100px; }
.msg_caption { width:100%; overflow:hidden; margin-bottom:1px;}
.msg_caption span { display:block; float:left; margin:0 2px; padding:4px 10px; background:#898989; cursor:pointer;color:white; }
.msg textarea{ width:300px; height:80px;height:100px;border:1px solid #000;}
</style>
</head>
<body>
<form>
<div class="msg">
<div class="msg_caption">
<span class="bigger">放大</span>
<span class="smaller">縮小</span>
</div>
<textarea id="comment" rows="8" cols="20">多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。
多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。
</textarea>
</div>
</form>
</body>
<script type="text/javascript">
/**
* 多行文本框的高度調(diào)整
* */
$(function () {
var $comment = $('#comment');
$('.bigger').click(function () {
if(!$comment.is(":animated")) {
if($comment.height() < 500) {
//$comment.height($comment.height() + 50);//版本1
$comment.animate({height: "+=50"}, 400);
}
}
});
$('.smaller').click(function () {
if(!$comment.is(":animated")) {
if($comment.height() > 50) {
//$comment.height($comment.height() - 50);
$comment.animate({height: "-=50"}, 400);
}
}
});
});
</script>
</html>
更改多行文本的滾動(dòng)條高度
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<script type="text/javascript" src="../../js/jquery-2.1.3.js"></script>
<title></title>
<style type="text/css">
* { margin:0; padding:0;font:normal 12px/17px Arial; }
.msg {width:300px; margin:100px; }
.msg_caption { width:100%; overflow:hidden; margin-bottom:1px;}
.msg_caption span { display:block; float:left; margin:0 2px; padding:4px 10px; background:#898989; cursor:pointer;color:white; }
.msg textarea{ width:300px; height:80px;height:100px;border:1px solid #000;}
</style>
</head>
<body>
<form>
<div class="msg">
<div class="msg_caption">
<span class="up">向上</span>
<span class="down">向下</span>
</div>
<textarea id="comment" rows="8" cols="20">多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。
多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。
多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。
多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。
多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。
多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。
多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。
多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。
多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。多行文本框高度變化。
</textarea>
</div>
</form>
</body>
<script type="text/javascript">
/**
* 多行文本框的滾動(dòng)條高度調(diào)整
* */
$(function () {
var $comment = $('#comment');
$('.up').click(function () {
if(!$comment.is(":animated")) {
if($comment.height() < 500) {
$comment.animate({scrollTop: "+=50"}, 400);
}
}
});
$('.down').click(function () {
if(!$comment.is(":animated")) {
if($comment.height() > 50) {
$comment.animate({scrollTop: "-=50"}, 400);
}
}
});
});
</script>
</html>
復(fù)選框應(yīng)用
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<script type="text/javascript" src="../../js/jquery-2.1.3.js"></script>
<title></title>
<style type="text/css">
input:focus, textarea:focus {
border: 1px solid#f00;
background: #fcc;
}
.focus {
border: 1px solid#f00;
background: #fcc;
}
</style>
</head>
<body>
<form>
你愛好的運(yùn)動(dòng)是?<br/>
<input type="checkbox" name="items" value="足球"/>足球
<input type="checkbox" name="items" value="籃球"/>籃球
<input type="checkbox" name="items" value="羽毛球"/>羽毛球
<input type="checkbox" name="items" value="乒乓球"/>乒乓球
<input type="button" id="checkedAll" value="全 選"/>
<input type="button" id="checkedNo" value="全不選"/>
<input type="button" id="checkedRev" value="反 選"/>
<input type="button" id="send" value="提交"/>
</form>
</body>
<script type="text/javascript">
/**
* 復(fù)選框應(yīng)用
* */
$(function () {
$("#checkedAll").click(function () {
$('[name=items]:checkbox').attr('checked', true);
});
$("#checkedNo").click(function () {
$('[name=items]:checkbox').attr('checked', false);
});
$("#checkedRev").click(function () {
$('[name=items]:checkbox').each(function () {
this.checked = !this.checked;
});
});
$("#send").click(function () {
var str = "你選中的是: \r\n";
$('[name=items]:checkbox:checked').each(function () {
str += $(this).val() + "\r\n";
});
alert(str);
});
})
</script>
</html>
- jquery EasyUI的formatter格式化函數(shù)代碼
- jQuery EasyUI API 中文文檔 - Form表單
- jquery表單驗(yàn)證使用插件formValidator
- jQuery實(shí)現(xiàn)form表單reset按鈕重置清空表單功能
- jQuery-serialize()輸出序列化form表單值的方法
- jquery實(shí)現(xiàn)ajax提交form表單的方法總結(jié)
- jquery序列化form表單使用ajax提交后處理返回的json數(shù)據(jù)
- jquery form 加載數(shù)據(jù)示例
- jquery動(dòng)態(tài)改變form屬性提交表單
- jquery中$(#form :input)與$(#form input)的區(qū)別
相關(guān)文章
jquery與js實(shí)現(xiàn)全選功能的區(qū)別
這篇文章主要介紹了jquery與js實(shí)現(xiàn)全選功能的區(qū)別,需要的朋友可以參考下2017-06-06
jquery+CSS3實(shí)現(xiàn)淘寶移動(dòng)網(wǎng)頁菜單效果
這篇文章主要介紹了jquery+CSS3實(shí)現(xiàn)淘寶移動(dòng)網(wǎng)頁菜單效果,實(shí)例分析了jquery操作頁面樣式動(dòng)態(tài)變換及熱區(qū)的選擇技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-08-08
google jQuery 引用文件,jQuery 引用地址集合(jquery 1.2.6至jquery1.5.2)
很多網(wǎng)站都是使用這種方式引入,客戶的瀏覽器可能已經(jīng)緩存過了 jquery??梢灾苯诱{(diào)用本地的,速度更快2011-04-04
jquery自動(dòng)填充勾選框即把勾選框打上true
jquery自動(dòng)填充勾選框,即把勾選框打上(true),然后通過ajax方式獲得勾選項(xiàng)列表,再把列表內(nèi)的選項(xiàng)打上2014-03-03
jQuery使用之標(biāo)記元素屬性用法實(shí)例
這篇文章主要介紹了jQuery使用之標(biāo)記元素屬性用法,實(shí)例分析了jQuery如何控制頁面,包含元素的屬性、css樣式風(fēng)格、DOM模型、表單元素和事件處理等使用技巧,需要的朋友可以參考下2015-01-01
jQuery插件HighCharts繪制2D餅圖效果示例【附demo源碼下載】
這篇文章主要介紹了jQuery插件HighCharts繪制2D餅圖效果,結(jié)合完整實(shí)例形式分析了jQuery使用HighCharts插件繪制餅圖效果的操作步驟與相關(guān)實(shí)現(xiàn)技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下2017-03-03
jquery點(diǎn)贊功能實(shí)現(xiàn)代碼 點(diǎn)個(gè)贊吧!
點(diǎn)贊功能很多地方都會(huì)出現(xiàn),如何實(shí)現(xiàn)愛心點(diǎn)贊功能,這篇文章主要為大家詳細(xì)介紹了jquery點(diǎn)贊功能實(shí)現(xiàn)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05
jQuery實(shí)現(xiàn)簡(jiǎn)單彈出框效果實(shí)例
這篇文章主要給大家介紹了關(guān)于jQuery實(shí)現(xiàn)簡(jiǎn)單彈出框效果的相關(guān)資料,幾天一直在研究JQuery,確實(shí)很好用,有很多需求都是要彈出框,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-06-06

