【问题标题】:Get form id in jquery Mobile 'pageshow'在 jquery Mobile 'pageshow' 中获取表单 ID
【发布时间】:2013-03-20 03:51:27
【问题描述】:

如何在 Jquery Mobile 的“pageshow”中获取当前页面的表单 ID?我可以通过这种方式获取当前活动页面的id。

$(document).on('pageshow', function () {
var id = $.mobile.activePage.attr('id'); 
});

【问题讨论】:

    标签: javascript jquery html css jquery-mobile


    【解决方案1】:

    可以这样做:

    $(document).on('pageshow', function () {
        var formID = $.mobile.activePage.find('form').attr('id'); 
    });
    

    工作示例:http://jsfiddle.net/Gajotres/CEAwG/

    【讨论】:

    • 该代码在 pageshow 中返回“未定义”,您的工作示例正在使用“pagebeforeshow”,您能否展示“pageshow”的示例
    • 相同的代码也适用于页面显示,只需在我的示例中更改即可。您可以添加一个页面示例吗?你也确定你的表格有一个ID吗?首先测试一下你的表单是否真的存在:alert($.mobile.activePage.find('form').html());
    • 是的,抱歉,它有效。我的 hoem 页面没有表格。谢谢先生!
    猜你喜欢
    • 2013-05-21
    • 1970-01-01
    • 1970-01-01
    • 2014-09-02
    • 2013-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多