Home  >  Article  >  Web Front-end  >  jquery gets radio value instance_jquery

jquery gets radio value instance_jquery

WBOY
WBOYOriginal
2016-05-16 16:33:491211browse

The example in this article describes the method of obtaining the radio value with jquery and is shared with everyone for your reference. The details are as follows:

Radio group radio:

Copy code The code is as follows:
$("input[@type=radio] [@checked]").val();

Radio group radio:

Copy code The code is as follows:
$("input[@type=radio] ").attr("checked",'2');//Set the item with value=2 as the currently selected item

Get the value of a set of radio selected items

Copy code The code is as follows:
var item = $('input[@name=items][@checked]' ).val();

The second element of the radio radio selection group is the currently selected value

Copy code The code is as follows:
$('input[@name=items]').get(1). checked = true

Old version of jquery

Copy code The code is as follows:
var_name = $("input[@name='radio_name']:checked") .val();

Versions after jquery 1.3
Copy code The code is as follows:
var_name = $("input[name='radio_name']:checked"). val();

Get jquery instance of radio value:

Copy code The code is as follows:
function getra(){

var_name = $("input[name='isspecialcnt']:checked").val();
//alert(var_name);
if(var_name=='1'){
$("#isspecialcntyes").show();
$("#isspecialcntno").hide();
}
if(var_name=='0'){
$("#isspecialcntyes").hide();
$("#isspecialcntno").show();
}
}






















I hope this article will be helpful to everyone’s JavaScript programming design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn