国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jquery 使用點滴函數代碼

2019-11-20 23:48:52
字體:
來源:轉載
供稿:網友
1、簡單的按鈕js事件 用于判斷和顯示提示
復制代碼 代碼如下:

<script type="text/javascript" language="javascript">
$(document).ready(function () {
$("#btnlogin").click(function () {
$("#lblInfo").html("");
var uid = $.trim($("#txtUsername").val());
var pwd = $.trim($("#txtPassword").val());
if (uid == "") {
$("#lblInfo").html("賬號不能為空");
$("#txtUsername").focus();
return false;
}
if (pwd == "") {
$("#lblInfo").html("密碼不能為空");
$("#txtPassword").focus();
return false;
}
});
});
</script>


2、下拉列表的處理
復制代碼 代碼如下:

function dropTypeChange()
{
var sel = $("#<%=dropType.ClientID %> option:selected").val();
if(sel=="-1")
{
$("#<%=txtNo.ClientID %>").attr('disabled',true);
}
else
{
$("#<%=txtNo.ClientID %>").attr('disabled',false);
}
}


//獲取第一個option的值
$('#test option:first').val();
//最后一個option的值
$('#test option:last').val();
//獲取第二個option的值
$('#test option:eq(1)').val();
//獲取選中的值
$('#test').val();
$('#test option:selected').val();
//設置值為2的option為選中狀態
$('#test').attr('value','2');
//設置第一個option為選中
$('#test option:last').attr('selected','selected');
$("#test").attr('value' , $('#test option:last').val());
$("#test").attr('value' , $('#test option').eq($('#test option').length - 1).val());
//獲取select的長度
$('#test option').length;
//添加一個option
$("#test").append("<option value='9'>ff</option>");
$("<option value='9'>ff</option>").appendTo("#test");
//添除選中項
$('#test option:selected').remove();
//指定項選中
$('#test option:first').remove();
//指定值被刪除
$('#test option').each(function(){
if( $(this).val() == '5'){
$(this).remove();
}
});
$('#test option[value=5]').remove();
//獲取第一個Group的標簽
$('#test optgroup:eq(0)').attr('label');
//獲取第二group下面第一個option的值
$('#test optgroup:eq(1) :option:eq(0)').val();
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 德阳市| 贡嘎县| 新安县| 历史| 新竹市| 仁化县| 宿迁市| 米泉市| 祁连县| 东港市| 贵州省| 景泰县| 周宁县| 浦北县| 新巴尔虎左旗| 南雄市| 正蓝旗| 邻水| 乌海市| 岳普湖县| 临夏县| 林州市| 武山县| 顺义区| 益阳市| 大埔区| 漠河县| 开阳县| 墨竹工卡县| 旬阳县| 黄石市| 永福县| 益阳市| 如皋市| 南乐县| 合水县| 武穴市| 信宜市| 云和县| 晋江市| 天等县|