Jquery獲取 設定各種input元素的值

2021-07-29 11:51:09 字數 792 閱讀 4944

radio按鈕

$("input[name='kstype']:checked").val()  // name=kstype 的radio按鈕集合中被選中的那個radio的value

文字框

var  str=$(「#txtname」).val();  //獲得文字框的值

$(「#txtname」).focus(   function()   ); //文字框獲取焦點**

$(「#txtname」).focus(   function()   ); //文字框獲取焦點**

$(「#txtname」).blur(   function()   ); //文字框失去焦點**

$(「#txtname」).trigger(「focus」); //讓文字框獲取焦點

select 控制項

$("#sel   option:selected ").val()  獲得被選中的項的值

$("#sel   option:selected ").text()  獲得被選中的項的文字

alert(obj.id);    // 用js語句獲得 obj的id,注意:呼叫時使用this引數,this就是呼叫本方法的dom元素。例:abc

。obj 相當於 document.getelementbyid('mydiv') 獲得的物件  

//若使用

jquery

,可以寫成

alert($(obj).html());  

jquery獲取各種高度

alert window height 瀏覽器時下視窗可視區域高度 alert document height 瀏覽器時下視窗文件的高度 alert document.body height 瀏覽器時下視窗文件body的高度 alert document.body outerheight true ...

jquery設定各種input指

獲取一組radio被選中項的值 var item input name items checked val 獲取select被選中項的文字 var item select name items option selected text select下拉框的第二個元素為當前選中值 select id ...

jQuery獲取各種高和寬

alert window height 瀏覽器時下視窗可視區域高度 02alert document height 瀏覽器時下視窗文件的高度 03alert document.body height 瀏覽器時下視窗文件body的高度 04alert document.body outerheight...