zoukankan      html  css  js  c++  java
  • jquery 单选框整个选中

    问题:遇到单选框,如图

    解决办法:利用jqurey click->checked

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script>
    <body>
    <span class="pay-item" >
                    <input type="radio" name="pay-item" class="big-radio" /><{$payment.app_display_name}>
    </span>
    <span class="pay-item" >
                    <input type="radio" name="pay-item" class="big-radio" /><{$payment.app_display_name}>
    </span>
    </body>
    </html>
    
    
    
    <script>
        $('.pay-item').bind('click',function(e){
            $(this).find('input[name=pay-item]')[0].checked = true;
        });
    
    </script>

     代码解析:其中pay-item 为span标签的class值,和id(‘#pay-item’)不一样

    input[name=pay-item] 为单选框的name;
     $('.pay-item').bind('click',function(e){
     $(this).find('input[name=pay-item]')[0].checked = true;
    }

    遇到在handlebar上的写法

    $('body').on('click', '.pay-item', function(e){
        $(this).find('input[name=pay-item]')[0].checked = true;
    })
    if (
    $(e)
    .find(".edit-item")
    .prop("checked")
    ) {
    $(e)
    .find(".edit-item")
    .prop("checked", false);
    } else {
    $(e)
    .find(".edit-item")
    .prop("checked", true);
    }
  • 相关阅读:
    准备ing
    六月的最后一星期
    对象及其内存管理 笔记
    数组及其内存管理 笔记
    笔记
    搜狐 云端服务组实习面试小记
    leetcode之Binary Tree Level Order Traversal
    数据库01-范式总结
    Tour UVa 1347 (DAG)
    Directed Acyclic Graph DAG(有向无环图)上的DP
  • 原文地址:https://www.cnblogs.com/lemonphp/p/5632458.html
Copyright © 2011-2022 走看看