<script type="text/javascript">
$(document).ready(function(){
$("input[type=radio][name=sex][value=1]").attr("checked",true);
});
</script> 您的性别:
<input type="radio" name="sex" value="1" <s:if test="user.sex==1">checked</s:if>/>男
<input type="radio" name="sex" value="0" <s:if test="user.sex==0">checked</s:if>/>女

获取radio的值:

谷歌了一下,大多跟我用的方法是一样的

var value = $("input[name='radio1'][type='radio'][checked]").val();

这句在IE、Safari(3.2)下测试通过,但是在FireFox、Chrome下却得不到选中的值。
仔细再看手册,发现“表单对象属性”这个列表。难道说对表单对象有专用的属性判断的方法?把代码改一下

var value = $("input[name='radio1'][type='radio']:checked").val();

jquery设置radio选中的更多相关文章

  1. JQuery控制radio选中和不选中方法总结

    一.设置选中方法 代码如下: $("input[name='名字']").get(0).checked=true; $("input[name='名字']"). ...

  2. Jquery 操作 radio选中值

    1.获取radio选中值 1.1  $('input:radio:checked').val(); 1.2  $("input[type='radio']:checked").va ...

  3. 设置checkbox选中,设置radio选中,根据值设置checkbox选中,checkbox勾选

    设置checkbox选中,设置radio选中,根据值设置checkbox选中,checkbox勾选 >>>>>>>>>>>>&g ...

  4. jQuery获取radio选中后的文字

    原文链接:http://blog.csdn.net/zhanyouwen/article/details/51393216 jQuery获取radio选中后的文字转载 2016年05月13日 10:3 ...

  5. jquery 获取radio选中的值

    如下案例:常用方法 1.获取选中值,三种方法都可以: $('input:radio:checked').val(): $("input[type='radio']:checked" ...

  6. Jquery 获取 radio选中值,select选中值

    随着Jquery的作用越来越大,使用的朋友也越来越多.在Web中,由于CheckBox.Radiobutton .DropDownList等控件使用的频率比较高,就关系到这些控件在Jquery中的操作 ...

  7. [转]jquery设置select选中,赋值等操作

    一.基础取值问题 例如<select class="selector"></select> 1.设置value为pxx的项选中 $(".selec ...

  8. jquery获取radio选中值及遍历

    使用jquery获取radio的值,最重要的是掌握jquery选择器的使用,在一个表单中我们通常是要获取被选中的那个radio项的值,所以要加checked来筛选,比如有以下的一些radio项:1.& ...

  9. jquery设置select选中的文本

    <select id="prov">  <option value="1">北京市</option>  <option ...

随机推荐

  1. windows 7 64bit安装apche php

    http://windows.php.net/download#php-5.6-ts-VC11-x64http://www.apachehaus.com/cgi-bin/download.plx 下载 ...

  2. STL - 迭代器 - 安插型迭代器

    list<, , , , , , , , }; cout << "** collection 1: **" << endl; ContainerUti ...

  3. MESI-CPU缓存一致性协议

    转http://blog.csdn.net/realxie/article/details/7317630 http://en.wikipedia.org/wiki/MESI_protocol MES ...

  4. vue computed 可以使用getter和setter

    var vm = new Vue({ data: { a: 1 }, computed: { // 仅读取 aDouble: function () { return this.a * 2 }, // ...

  5. Android源代码目录结构(转)

    https://android.googlesource.com/ Android 2.2 |-- Makefile |-- bionic               (bionic C库) |-- ...

  6. CompletableFuture 详解

    转 http://www.jianshu.com/p/6f3ee90ab7d3 CompletableFuture类实现了CompletionStage和Future接口.Future是Java 5添 ...

  7. Java线程-volatile不能保证原子性

    下面是一共通过volatile实现原子性的例子: 通过建立100个线程,计算number这个变量最后的结果. package com.Sychronized; public class Volatil ...

  8. apache绑定多个域名

    在httpd.conf里, 1.把#NameVirtualHost *:80前的注释去掉2.ServerName 127.0.0.1 修改成ServerName 72.167.11.303.#Name ...

  9. 列举一些常见的系统系能瓶颈 Common Bottlenecks

    http://www.nowamagic.net/librarys/veda/detail/2408在 Zen And The Art Of Scaling - A Koan And Epigram ...

  10. 三维模型 DAE 导出格式结合 OpenGLES 要素浅析

    三维模型 DAE 导出格式结合 OpenGLES 要素浅析 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致&quo ...