zoukankan      html  css  js  c++  java
  • jqure获取单选按钮的值(比如性别)

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

    1.<input type="radio" name="testradio" value="jquery获取radio的值" />jquery获取radio的值
    2.<input type="radio" name="testradio" value="jquery获取checkbox的值" />jquery获取checkbox的值
    3.<input type="radio" name="testradio" value="jquery获取select的值" />jquery获取select的值
    要想获取某个radio的值有以下的几种方法,直接给出代码:
    1、

    1.$('input[name="testradio"]:checked').val();
    2.$('input:radio:checked').val();
    3.$('input[@name="testradio"][checked]');
    4.$('input[name="testradio"]').filter(':checked');差不多挺全的了,如果我们要遍历name为testradio的所有radio呢,代码如下

    1.$('input[name="testradio"]').each(function(){2.alert(this.value);3.});如果要取具体某个radio的值,比如第二个radio的值,这样写
    2.$('input[name="testradio"]:eq(1)').val()
  • 相关阅读:
    A visual proof that neural nets can compute any function 2
    Matrix
    Formula
    ID and CLASS
    hugeng007_diary01_the living way
    the mathematical knowledge
    sys.argv[]
    The Convolutional Networks
    DVWA之XSS (跨站脚本攻击)存储型+反射型。
    DVWA之 File Inclusion 文件包含
  • 原文地址:https://www.cnblogs.com/WZH75171992/p/4153238.html
Copyright © 2011-2022 走看看