TextBox:
var str = $('#txt').val();
$('#txt').val("Set Lbl Value");
//文本框,文本区域:
$ ( " #text_id " ) . attr ( " value " , '' ) ; //清空内容 $ ( " #text_id " ) . attr ( " value " , ' test ' ) ; //填充内容
LABLE:
var str = $('#lbl').text();
$('#lbl').text("Set Lbl 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();
//下拉框select: $ ( " #select_id " ) . attr ( " value " , ' test ' ) ; //设置value=test的项目为当前选中项 $ ( " <option value='test'>test</option><option value='test2'>test2</option> " ) . 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 () ; }) ;