JQuery 取值賦值

2021-08-25 09:40:16 字數 1088 閱讀 4144

<

input

type="

text

"name="

textname"id

="text_id

"value=""

>

取值等等;

function

get_form_value()

}) }

對表單的其他處理:

// 控制表單元素:

// 文字框,文字區域: $

("#text_id")

.attr("

value",

'');// 清空內容 $

("#text_id")

.attr("

value",

'test')

;// 填充內容

// 多選框checkbox : $(

"#chk_id")

.attr("

checked",

'');// 未選中的值 $

("#chk_id")

.attr("

checked",

true);

// 選中的值 if

($("

#chk_id")

.attr('

checked')

==undefined

)// 判斷是否已經選中

// 單選組radio : $

("input[@type=radio]")

.attr("

checked",

'10')

;// 設定value=10 的單選按鈕為當前選中項

// 下拉框select : $(

"#select_id")

.attr("

value",

'test')

;// 設定value=test 的專案為當前選中項 $

("test

test2 ")

.("#select_id")

// 新增下拉框的option $

("#select_id")

.empty

() ; // 清空下拉框

jquery 取值賦值

文字框操作 取值 text id attr value text id val input type text val 清除 text id attr value 賦值 text id attr value 123 單選框操作 取值 input type radio checked val inpu...

jquery取值賦值

a val 1 id為a的值就是1了 jquery中都這樣,賦值的時候作為引數傳給函式,和單純的js有區別,像 a html 1 a text 1 都是賦值 a html a text 都是取值,取html,取text文字 nput class required 查詢出所有input標籤,且clas...

Jquery表單取值賦值

jquery表單取值賦值的一些基本操作2008 12 25 03 17 獲得text.areatext的值 var textval text id attr value 或者 var textval text id val 獲取單選按鈕的值 var valradio input type radio...