layui——父页面获取layer.open弹窗中的值
1、获取input中的值
content页面
1 2 3 | <div style= "padding: 0 10px;margin-top:10px" > <input type= "text" id= "refuseReason" name= "refuseReason" placeholder= "请输入拒绝理由" class = "layui-input" > </div> |
父页面
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | layer.open({ type: 1 , title: "拒绝理由" , content: '<div style="padding: 0 10px;margin-top:10px">' + '<input type="text" id="refuseReason" name="refuseReason" placeholder="请输入拒绝理由" class="layui-input">' + '</div>' , area: [ '500px' , '150px' ], btn: [ '提交' , '取消' ], btnAlign: 'c' , resize: true , yes:(index,layero)=>{ // 获取content页面中id为refuseReason的值 const refuseReason = top.$( '#refuseReason' ).val(); }, cancel:(index, layero)=>{} }) |
2、获取select中选中的值
content页面
1 2 3 4 5 | <select id= "groupId" name= "groupId" xm-select= "group" > <span th:each= "info : ${groupList}" > <option th:text= "${info.st_g_name}" th:value= "${info.st_g_id}" ></option> </span> </select> |
父页面
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | layer.open({ type: 2 , title: "标题" , area: [ '600px' , '500px' ], content: "/page/layerOpen" , //请求后端返回页面地址 btn: [ '提交' , '取消' ], yes: function(index, layero){ //得到iframe页的窗口对象,执行iframe页的方法: var iframeWin = window[layero.find( 'iframe' )[ 0 ][ 'name' ]]; // 获取页面中xm-select属性为group的下拉选择框选中的值 var selectGroupData = iframeWin.layui.formSelects.value( 'group' , 'val' ); console.log(selectGroupData); } }) |
3、
作者:假装空白
欢迎任何形式的转载,但请务必注明出处。
限于本人水平,如果文章和代码有表述不当之处,还请不吝赐教。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)