jquery radio operation code_jquery
May 16, 2016 pm 06:09 PM//Set the second one as selected
//if(<%=rows["sex"]%>=="2"){$(':radio[name=sex]' ).eq(1).attr('checked',true);}
//Design value=2 to be in the selected state
//if(<%=rows["sex"] .ToString() %>=='2'){$("input[name='sex']").attr("checked",'2');}
if (<%=rows["sex"]%>=="2"){$("input[name=sex][value=2]").attr("checked",true);}
I did something NB today and none of the above three conditions worked. The reason is that the local database has been operating on the remote database.
JQuery gets radio
<div>
<input id="Radio1" type="radio" name= "rad" value="1" checked />1
<input id="Radio2" type="radio" name="rad" value="2" />2
<input id ="Radio3" type="radio" name="rad" value="3" />3
<input id="Radio4" type="radio" name="rad" value="4" / >4
<input id="Radio5" type="radio" name="rad" value="5" />5
<input id="Button1" type="button" value ="button" onclick="return Button1_onclick()" />
<input id="Button2" type="button" value="button" onclick="return Button2_onclick()" />
</div>
<script language="javascript" type="text/javascript">
// <![CDATA[
function Button1_onclick() {
$("input").each(function () {
if (this.type == 'radio') {
alert($(this).val());
}
});
}
function Button2_onclick() {
//alert($("input[@type=radio]:checked").val());
//alert($ ("input[name='rad']:checked").val());
alert($("input[@type=radio]").val());
}
// ]]>
</script>

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Detailed explanation of jQuery reference methods: Quick start guide

How to use PUT request method in jQuery?

How to remove the height attribute of an element with jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page

Use jQuery to modify the text content of all a tags

60 years in the making: NASA confirms hypothesis on Earth\'s global electric field

Understand the role and application scenarios of eq in jQuery

How to tell if a jQuery element has a specific attribute?
