jquery mobile 无法隐藏提交按钮 [英] jquery mobile cannot hide submit button

查看:24
本文介绍了jquery mobile 无法隐藏提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是最新版本的 jquery mobile,我的问题是我给了一个提交按钮一个 ID,然后添加了一些 css 来将 ID 设置为 display:none;

由于某种原因,这不起作用.

以前有人遇到过这个问题吗?

解决方案

如果没有任何代码,很难说出您想要做什么,但我认为问题源于 jQuery Mobile 没有为您现有的按钮设置样式而是隐藏元素并将其包装在一个新的 div 中,该 div 的样式看起来和行为都像一个按钮.

按钮的当前 jQuery Mobile 标记如下所示:

<div data-theme="e" class="ui-btn ui-btn-inline ui-btn-corner-all ui-shadow ui-btn-hover-e ui-btn-down-e" aria-disabled="false"><span class="ui-btn-inner ui-btn-corner-all"><span class="ui-btn-text">提交</span></span><input type="submit" id="submit_btn" value="Submit" data-theme="e" data-inline="true" class="ui-btn-hidden" aria-disabled="false">

所以你寻找与 ui-btn 类最近的祖先并隐藏它:

$('#submit_btn').closest('.ui-btn').hide();

如果有更好的方法来做到这一点,我很想知道.这是一个 fiddle 展示了我的解决方案.

I am using the latest version of jquery mobile and my problem is that I have given a submit button an ID and then added some css to set the ID to display:none;

For some reason this does not work.

Has anyone had this problem before?

解决方案

It's hard to tell what you're trying to do without any code but I think the problem stems from the fact that jQuery Mobile doesn't style your existing button but rather, hides the element and wraps it in a new div which is styled to look and behave like a button.

The current jQuery Mobile markup for a button looks like this:

<div data-theme="e" class="ui-btn ui-btn-inline ui-btn-corner-all ui-shadow ui-btn-hover-e ui-btn-down-e" aria-disabled="false">
    <span class="ui-btn-inner ui-btn-corner-all">
        <span class="ui-btn-text">Submit</span>
    </span>
    <input type="submit" id="submit_btn" value="Submit" data-theme="e" data-inline="true" class="ui-btn-hidden" aria-disabled="false">
</div>

So you look for the closest ancestor with the class ui-btn and hide it:

$('#submit_btn').closest('.ui-btn').hide();

If there's a better way to do this, I'd love to know about it. Here's a fiddle that shows my solution in action.

这篇关于jquery mobile 无法隐藏提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆