TEXTBOX:
var str =$("#txt").val();
$("#txt").val(Value);
//文本框,文本区域:
$("#text_id").attr("value",'');//清空内容
$("#text_id").attr("value",'test');//填充内容
LABLE:
var str =$("#lbl").text();
$("#lbl").text(Value);
/*获取单选按钮的值*/
var valradio =$("input[@type=radio][@checked]").val();
/*获取一组名为(items)的radio被选中项的值*/
var item =$('input[@name=items][@checked]').val();
/* 获取复选框的值*/
var checkboxval =$("#checkbox_id").attr("value");
/* 获取下拉列表的值*/
var selectval =$('#select_id').val();
//多选框checkbox:
$("#chk_id").attr("checked",'');//使其未勾选
$("#chk_id").attr("checked",true);//勾选
if($("#chk_id").attr('checked')==true)//判断是否已经选中
单选组radio:
$("input[@type=radio]").attr("checked",'2');//设置value=2的项目为当前选中项
//下拉框select:
$("#select_id").attr("value",'test');//设置value=test的项目为当前选中项
$("testtest2").appendTo("#select_id")//添加下拉框的 option
$("#select_id").empty();//清空下拉框
获取一组名为 (items)的radio被选中项的值
var item =$('input[@name=items][@checked]').val();//若未被选中 则val() = undefined
获 取select被选中项的文本
var item =$("select[@name=items] option[@selected]").text();
select下拉框的第二个元素为当前选中值
$('#select_id')[0].selectedIndex= 1;
radio单选组的第二个元素为当前选中值
$('input[@name=items]').get(1).checked= true;
//重置表单
$("form").each(function(){
.reset();
});
以下是设置img的路径
$("#img1").attr("src","Imges/test.jpg");
var str =$("#txt").val();
$("#txt").val(Value);
//文本框,文本区域:
$("#text_id").attr("value",'');//清空内容
$("#text_id").attr("value",'test');//填充内容
LABLE:
var str =$("#lbl").text();
$("#lbl").text(Value);
/*获取单选按钮的值*/
var valradio =$("input[@type=radio][@checked]").val();
/*获取一组名为(items)的radio被选中项的值*/
var item =$('input[@name=items][@checked]').val();
/* 获取复选框的值*/
var checkboxval =$("#checkbox_id").attr("value");
/* 获取下拉列表的值*/
var selectval =$('#select_id').val();
//多选框checkbox:
$("#chk_id").attr("checked",'');//使其未勾选
$("#chk_id").attr("checked",true);//勾选
if($("#chk_id").attr('checked')==true)//判断是否已经选中
单选组radio:
$("input[@type=radio]").attr("checked",'2');//设置value=2的项目为当前选中项
//下拉框select:
$("#select_id").attr("value",'test');//设置value=test的项目为当前选中项
$("testtest2").appendTo("#select_id")//添加下拉框的 option
$("#select_id").empty();//清空下拉框
获取一组名为 (items)的radio被选中项的值
var item =$('input[@name=items][@checked]').val();//若未被选中 则val() = undefined
获 取select被选中项的文本
var item =$("select[@name=items] option[@selected]").text();
select下拉框的第二个元素为当前选中值
$('#select_id')[0].selectedIndex= 1;
radio单选组的第二个元素为当前选中值
$('input[@name=items]').get(1).checked= true;
//重置表单
$("form").each(function(){
.reset();
});
以下是设置img的路径
$("#img1").attr("src","Imges/test.jpg");
标签:
控件,取值,赋值
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“Jquery给基本控件的取值、赋值示例”评论...
更新动态
2025年05月12日
2025年05月12日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]