iframe页面修改parent页面的隐藏input部件value值,不能触发change事件。
来源:互联网 发布:新概念作文知乎 编辑:程序博客网 时间:2024/05/21 11:34
实现一个根据iframe页面返回充值卡类型不同,安排不同的input部件。
点击选择弹出一个iframe,点击充值卡数据行,返回1、充值卡类型。2、充值卡id(用的UUID)。3、充值卡号(字符串)。
遇到的问题是当iframe选择充值卡时,无法获取parent页面input部件value值的change事件。
parent页js
$("#id_card_type").change(function(){//事件无法捕获});parent页form
<form id="frm" method="post" action="/bill/recharge/new/"> <input id="id_card_type" name="card_type" type="hidden" /> <input id="id_card_id" name="card_id" type="hidden" /> <label>卡号</label><input id="id_cardno" name="cardno" readonly="True" type="text" /> <span id="btnSelectCard" >选择</span></form>
iframe页js
$(this).children().click(function(){<span style="white-space:pre"></span>var cid=$(this).parent('tr').attr('item_id');var cn=$(this).parent('tr').children('td').eq(0).html();var ct=$(this).parent('tr').attr('item_type');$('#id_card_id', window.parent.document).val(cid);$('#id_cardno', window.parent.document).val(cn);$('#id_card_type', window.parent.document).val(ct);});
解决如下:
$(this).children().click(function(){ var cid=$(this).parent('tr').attr('item_id'); var cn=$(this).parent('tr').children('td').eq(0).html(); var ct=$(this).parent('tr').attr('item_type'); $('#id_card_id', window.parent.document).val(cid); $('#id_cardno', window.parent.document).val(cn); $('#id_card_type', window.parent.document).val(ct); //$('#id_card_type', window.parent.document).trigger('change'); //无效 window.parent.$('#id_card_type').trigger('change'); //有效});
0 0
- iframe页面修改parent页面的隐藏input部件value值,不能触发change事件。
- jQuery的change方法什么时候触发? 你绝对意想不到,即使你通过jQuery修改了input标签的value值(即修改内存中的DOM树中的input),也不会触发change事件,不会,不会
- onchange监听input值变化及input隐藏后change事件不触发的原因与解决方法
- 赋值方式触发input的change事件
- iframe刷新parent页面
- jQuery控制input的value值,代码中有值,但是页面中不能显示的原因
- INPUT[type=file]的change事件不触发问题
- JQ JS 改变value值不触发change事件
- iframe如何触发父元素事件以及父页面控制iframe子页面元素
- [Js]判断iframe内的页面是否滚动到底部触发事件
- 去掉手机页面a,button,input默认触发事件
- ie中的radio click()不能触发radio的change事件
- input file change事件只触发一次
- iframe不能充满页面
- 页面关闭触发事件
- JS改变input的value值不触发onchange事件解决方案
- JS改变input的value值不触发onchange事件解决方案
- JS改变input的value值不触发onchange事件解决方案
- ubuntu apt 相关命令
- block面试问题
- ubuntu使用过程命令
- 自定义ActionBar样式
- Alpha、Beta、RC、GA版本的区别
- iframe页面修改parent页面的隐藏input部件value值,不能触发change事件。
- QUSTOJ1229:最大子矩阵
- UIResponder+Router 时间响应机制来响应
- 第10周项目1程序的填充与阅读(总结getchar()接受字符时的规律)
- 《java编程思想》第4章练习
- malloc对应的汇编语句
- 关于Object类的equals()和hashcode()
- 在android settings.db数据库中添加一项新的设置
- 第10周项目1-程序填充与阅读1及其拓展