WEUI switch 如何取值?

 

 

let id =  $(this).attr("id");
            let name =  $(this).attr("data-name");

 

 

 

HTML:

<div >
                                    <div class="weui-cell__bd">数据统计</div>
                                    <div class="weui-cell__ft">
                                        <label class="weui-switch-cp"><input class="weui-switch-cp__input" value="0002" ></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" ></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" ></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;

 

相关文章:

  • 2021-06-14
  • 2022-12-23
  • 2023-01-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-06
  • 2021-05-09
  • 2021-09-10
猜你喜欢
  • 2022-12-23
  • 2021-10-28
  • 2022-12-23
  • 2021-07-01
  • 2021-10-30
  • 2021-12-06
  • 2022-12-23
相关资源
相似解决方案