欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Jquery給基本控件的取值、賦值示例

 更新時(shí)間:2014年05月23日 10:21:24   作者:  
這篇文章主要介紹通過Jquery如何給基本控件的取值、賦值,需要的朋友可以參考下
TEXTBOX:

var str =$("#txt").val();

$("#txt").val(Value);

//文本框,文本區(qū)域:

$("#text_id").attr("value",'');//清空內(nèi)容

$("#text_id").attr("value",'test');//填充內(nèi)容

LABLE:

var str =$("#lbl").text();

$("#lbl").text(Value);

/*獲取單選按鈕的值*/

var valradio =$("input[@type=radio][@checked]").val();

/*獲取一組名為(items)的radio被選中項(xiàng)的值*/

var item =$('input[@name=items][@checked]').val();

/* 獲取復(fù)選框的值*/

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)//判斷是否已經(jīng)選中

單選組radio:

$("input[@type=radio]").attr("checked",'2');//設(shè)置value=2的項(xiàng)目為當(dāng)前選中項(xiàng)

//下拉框select:

$("#select_id").attr("value",'test');//設(shè)置value=test的項(xiàng)目為當(dāng)前選中項(xiàng)

$("testtest2").appendTo("#select_id")//添加下拉框的 option

$("#select_id").empty();//清空下拉框

獲取一組名為 (items)的radio被選中項(xiàng)的值

var item =$('input[@name=items][@checked]').val();//若未被選中 則val() = undefined

獲 取select被選中項(xiàng)的文本

var item =$("select[@name=items] option[@selected]").text();

select下拉框的第二個(gè)元素為當(dāng)前選中值

$('#select_id')[0].selectedIndex= 1;

radio單選組的第二個(gè)元素為當(dāng)前選中值

$('input[@name=items]').get(1).checked= true;

//重置表單

$("form").each(function(){

.reset();

});

以下是設(shè)置img的路徑

$("#img1").attr("src","Imges/test.jpg");

相關(guān)文章

最新評(píng)論