【问题标题】:Get checkbox selected value from list view从列表视图中获取复选框选定的值
【发布时间】:2017-04-18 11:36:30
【问题描述】:

下面是我的代码,我在 ul 中绑定工作日,我正在使用列表视图和模板,它工作正常,但我需要在选中复选框时获取值需要帮助,复选框可以选择多个,所以我可以有多个值

   <div data-role="view">
    <ul data-role="listview" data-style="inset" data-template="script-id" data-source="listData"></ul>
    <script id="script-id" type="text/x-kendo-template">
        <div>
            <input type="checkbox" class="checkclass"   />
             <h3 class="checkclass">#: week #</h3>

        </div>
    </script>
    </div>

//data to bind list template
  var listData = [{ week: 'Monday' },
               { week: 'Tuesday' },
               { week: 'Saturday ', },
               { week: 'Sunday', }]

【问题讨论】:

    标签: javascript jquery jquery-mobile checkbox kendo-mobile


    【解决方案1】:

    您可以使用on() 方法注册监听器。所以在你的情况下:

    $(".checkboxclass").on("change", function(){
       if(this.checked) {
            $(this).val();
        }
    })
    

    【讨论】:

    • @thanks,但我在 this.val() 附近遇到错误“未捕获的类型错误:this.val 不是函数”
    • 是的,现在它没有给我任何错误,但给我的价值是“开”的价值
    • 因为你还没有定义值。这样做:
    • 是的,我如何在复选框值中定义语言你能帮我吗?复选框值应该是动态绑定的
    • 请粘贴您创建复选框的代码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-26
    • 2012-05-03
    • 1970-01-01
    • 2015-01-29
    • 1970-01-01
    相关资源
    最近更新 更多