zoukankan      html  css  js  c++  java
  • jQuery实现点击单选按钮后赋值,点击其他按钮则隐藏

    <input type="radio" name="content" value="" id="other">其他
    <span class="content"></span>

    <script>
    $(":radio[name='content']").click(function(){
    var index = $(":radio[name='content']").index($(this));
    if(index == 3)
    $('.content').html('<textarea class="form-control" rows="10" style="resize: vertical;" name="content" placeholder="请说明你的原因"></textarea>');
    else
    $('.content').html('<textarea class="form-control hide" rows="10" style="resize: vertical;" placeholder="请说明你的原因"></textarea>');
    });

    </script>

    其实有一种比较简单的方法,只不过我这里是给span标签赋值的标签,所以写的啰嗦了点,下面是比较简便的方法


    $(":radio[name='content']").click(function(){
        var index = $(":radio[name='content']").index($(this));
        if(index == 1) //选中第2个时,div显示
            $(div).show();
        else //当被选中的不是第2个时,div隐藏
            $(div).hide();
     });



  • 相关阅读:
    git知识点总结
    自动化进阶
    unittest单元测试框架
    自动化测试模型
    webdriver
    python文件处理
    uva 11077 置换
    poj 1066 Treasure Hunt
    poj 2661 Factstone Benchmark
    hdu 4180
  • 原文地址:https://www.cnblogs.com/a-record/p/8474107.html
Copyright © 2011-2022 走看看