jQuery移动显示和隐藏似乎不适用于iPhone

时间:2011-12-09 12:52:57

标签: iphone jquery-mobile show-hide

我正在尝试使用jQuery show并隐藏哪些似乎在Safari中正常工作,当我在iPhone上试用它时,它根本不起作用。这是我的代码;

<script type="text/javascript">

$("#showSearch").click(function () {
  $("#searchform").show(1000);

});
</script>

这是一个按钮,点击后会显示搜索表单。该表格未在iPhone上显示。此外,当我在其中添加$('#showSearch').remove();时,它不会被删除,即使我添加一个函数作为show()的第二个参数,它仍然不会隐藏按钮。

感谢您的帮助。

2 个答案:

答案 0 :(得分:7)

jQuery Docs:

直播示例:

JS

$('#viewMeButton').click(function() {
   $('#viewMe').toggle(); // used toggle instead of .show() or .hide()
});

$('#removeMeButton').click(function() {
   $('#removeMe').remove(); 
});

HTML

<div data-role="page" id="home">
    <div data-role="content">
        <div id="viewMe">
            Hello I'm in the div tag, can you see me?
        </div>
        <br />
        <button id="viewMeButton">Show / Hide</button>
        <br />
        <div id="removeMe">
            Click the button to remove me
        </div>
        <br />
        <button id="removeMeButton">Remove Me</button>
    </div>
</div>

答案 1 :(得分:0)

我知道这是一个老问题,但我最近遇到了类似的问题。希望如果他们也发现这个问题,这将有助于其他人。

我试图在JQM网格中隐藏一组ui-block- *元素。在相同的网格单元格上,我对iPhone的媒体查询设置为display:block!important。那是胜利。

在我的情况下,!important指令是不必要的,当我删除它时,对hide()和show()的调用开始按预期工作。

相关问题