zoukankan      html  css  js  c++  java
  • 点击checkbox 向input 里面传值显示

    文本框显示
    <input type="text" id="textareashow" name="" class="margin-bottom-10 newbz floatleft"/>
    
    check1:
    <input type="checkbox" data-type="checkbox" data-value="等通知放货(送货)" value="等通知放货(送货)">等通知放货(送货)
    
    check2:
    <input type="checkbox" data-type="checkbox" data-value="等通知放货(自提)" value="等通知放货(自提)">等通知放货(自提)
    <script type="text/javascript">
                $(function() {
                    $('[data-type="checkbox"]').click(function() {
                        var data_value = $(this).attr('data-value'),
                            txtalso = $.trim($("#textareashow").val());
                        if ($(this).prop("checked")) {
                            if (txtalso.length > 0) {
                                if (txtalso.indexOf(data_value + ',') != -1) {
                                    return;
                                } else {
                                    txtalso += data_value + ',';
                                }
                            } else {
                                txtalso = data_value + ',';
                            }
                        } else {
                            if (txtalso.indexOf(data_value + ',') != -1) {
                                txtalso = txtalso.replace(data_value + ',', '');
                            }
                        }
                        $("#textareashow").val(txtalso);
                    });
                });
            </script>

     

  • 相关阅读:
    导入导出模块
    jQuery复习
    vue记录
    angular 初探之父子组件之间传递数据
    webpack
    go语言语法记录
    dom元素的滚动(如何实现点击展开更多功能)
    正则回忆录
    Attributes 和 properties区别和联系?
    显示 隐藏DIV的技巧
  • 原文地址:https://www.cnblogs.com/dazhangli/p/6295885.html
Copyright © 2011-2022 走看看