如题,开关组件,通过js后台获取的值,但是再编辑的时候我想给开和关设置不同的value值,这样就可以用序列化再次传递到后台,不想使用它默认的0,1

解决方案 »

  1.   

    最简单的方法就是外面加个div,然后用innerHTML
      

  2.   

    <div class="form-group">
                <label>性别</label>
                <div>
                    <input name="gender" type="checkbox" data-size="small">
                </div>
    </div>
    $('[name="gender"]').bootstrapSwitch({
                    onText: "男",
                    offText: "女",
                    onColor: "success",
                    offColor: "info",
                    size: "small",
                    onSwitchChange: function (event, state) {
                        if (state == true) {
                            $(this).val("1");
                        } else {
                            $(this).val("0");
                        }
                    }
                })请教下大神,这个位置写哪里...
      

  3.   

    写script标签里