【问题标题】:Button Submit on a form is not working jquery mobile表单上的按钮提交不起作用jquery mobile
【发布时间】:2013-08-08 03:40:03
【问题描述】:

按下按钮时,我想提醒两个输入中的两个值。但是,这不起作用,页面只是重定向到 jquery mobile 中的主页。

JS

$('newann').submit( function () {
    alert($('#t').val());
    alert($('#m').val());
});

HTML

<form id="newann" name="newann">
    <input type="text" id="t" placeholder="Title" />
    <input type="text" id="m" placeholder="Add more..." />
    <button type="submit" name="submit">Publish News</button>
</form>

【问题讨论】:

    标签: jquery forms button mobile submit


    【解决方案1】:

    Selector syntax incorrect.您忘记添加#(假设选择id

    $('#newann').submit( function () {
        alert($('#t').val());
        alert($('#m').val());
    });
    

    【讨论】:

      【解决方案2】:

      您的选择器错误。它应该是 $('#newann') 因为 "newann" 是表单的 id。

      您应该使用 .(dot) 作为类选择器,使用 #(hash) 作为 id 选择器。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-10-10
        • 2016-09-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多