【问题标题】:How to get easyui datebox content if it is placed inside Iframe如果将easyui datebox内容放在Iframe中,如何获取它
【发布时间】:2014-01-22 12:24:41
【问题描述】:

我尝试使用以下代码访问放置在 Iframe 中的 easyui datebox 内容,但没有成功。

alert($("#documentFrame").contents().find("#field6").datebox('getValue');

#documentFrame 是 Iframe ID,#field6 ID 是日期框。

使用以下代码获取文本框的值可以正常工作。

alert($("#documentFrame").contents().find("#field2").val());

#documentFrame 是 Iframe ID,#field2 是输入框 ID。

如何获取日期框值?

【问题讨论】:

    标签: jquery html iframe jquery-easyui datebox


    【解决方案1】:

    要完成获取放置在 Iframe 中的日期框内容的过程,您可以按照以下步骤操作:

    您需要在您的 iframe 文档中编写如下函数来返回日期框值。

    代码

    function getValue(value){
        var id='#'+value;
        var val= $(id).datebox('getValue');
        return val;
    }
    

    您可以从父文档调用 getValue() 方法并将日期框组件 ID 作为参数传递给 getValue() 方法。

    从 Iframe 父文档调用 getValue() 的代码

    value = window.frames[0].getValue('field ID');
    alert(value);
    

    谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-13
      • 2010-09-15
      • 2017-05-22
      • 2021-08-22
      相关资源
      最近更新 更多