WEUI switch 如何取值?

Posted zxyun

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WEUI switch 如何取值?相关的知识,希望对你有一定的参考价值。

 

 

技术分享图片

 

 

 

html

<div id="codeList"><div class="weui-cell weui-cell_switch">
                                    <div class="weui-cell__bd">数据统计</div>
                                    <div class="weui-cell__ft">
                                        <label class="weui-switch-cp"><input class="weui-switch-cp__input" value="0002" id="0002" type="checkbox" checked="checked"><div class="weui-switch-cp__box"></div>
                                        </label>
                                    </div>
                                </div><div class="weui-cell weui-cell_switch">
                                    <div class="weui-cell__bd">管理员</div>
                                    <div class="weui-cell__ft">
                                        <label class="weui-switch-cp"><input class="weui-switch-cp__input" value="0003" id="0003" type="checkbox" checked="checked"><div class="weui-switch-cp__box"></div>
                                        </label>
                                    </div>
                                </div><div class="weui-cell weui-cell_switch">
                                    <div class="weui-cell__bd">用户画像</div>
                                    <div class="weui-cell__ft">
                                        <label class="weui-switch-cp"><input class="weui-switch-cp__input" value="0000" id="0000" type="checkbox" checked="checked"><div class="weui-switch-cp__box"></div>
                                        </label>
                                    </div>

 

 

取值操作:

 

functionCode = ‘‘;
    $(".weui-switch-cp__input").each(function(){
        if($(this).prop(‘checked‘)){
            functionCode = functionCode + $(this).val() + ",";
        }
    });
    if(functionCode.length > 0){
        functionCode = functionCode.substr(0, functionCode.length - 1);
    }
    obj.functionCode = functionCode;

 

以上是关于WEUI switch 如何取值?的主要内容,如果未能解决你的问题,请参考以下文章

jqueryweui关于switch css与js结合

switch在vue中实现原理

switch在vue中实现原理

switch语句(上)(转载)

如何从片段到活动而不会干扰片段的可重用性

swtich能判断取值范围吗