Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
135 views
in Technique[技术] by (71.8m points)

layui如何获取switch开关的值

layui监听表单提交后,获取data.field表单的值里面没有switch开关的开启或者关闭的值,如何直接通过js获取switch开关的值,不是用监听switch的形式


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
layui监听switch开关
form.on('switch(filter)', function(data){
  console.log(data.elem);         // 得到checkbox原始DOM对象
  console.log(data.elem.checked); // 开关是否开启,true或者false
  console.log(data.value);        // 开关value值,也可以通过data.elem.value得到
  console.log(data.othis);        // 得到美化后的DOM对象
})

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...