大家好,小淋來為大家解答以上問題。inputrate,inputradio很多人還不知道,現在讓我們一起來看看吧!
使用jquery獲取radio的值,最重要的是掌握jquery選擇器的使用。在一個表單中,我們通常要獲取選中的單選項的值,所以我們必須在filter中添加checked。例如,有些單選按鈕如下:
1.輸入type=' radio ' name=' test radio ' value=' jquery獲取radio的值'/jquery獲取radio的值br/2。input type=' radio ' name=' test radio ' value=' Jquery獲取復選框的值'/Jquery獲取復選框的值br/3。input type=' radio ' name=' test radio ' value=' jQuery獲取select的值'/jquery獲取select的值br/
要得到一個電臺的值,有以下方法,直接給出代碼:
1、
1.$(' input[name=' test radio ']: checked ')。val();2、
1.$('input:radio:checked ')。val();3、
1.$(' input[@ name=' test radio '][checked]');4、
1.$('input[name='testradio']')。過濾器(“:已檢查”);
差不多完成了。如果我們想遍歷所有名為testradio的無線電,該怎么辦?代碼如下所示
1.$('input[name='testradio']')。每個(function(){ 2 . alert(this . value);3.});如果你想得到一個特定無線電的值,比如第二個無線電的值,可以這樣寫
1.$(' input[name=' test radio ']: eq(1)')。瓦爾()
本文到此結束,希望對大家有所幫助。