当在 jquery 中触发文本字段 onfocus 事件时,标题不固定

Posted

技术标签:

【中文标题】当在 jquery 中触发文本字段 onfocus 事件时,标题不固定【英文标题】:Header is not fixed when textfield onfocus event fired in jquery 【发布时间】:2013-09-05 12:30:37 【问题描述】:

当在 jquery 中触发 textfield onfocus 事件时,即使我使用 data-position="fixed" 作为标题,标题也会向上/向下移动。任何人都可以在 onfocus 和 onblur 调用时帮助如何修复标题?

这里是html代码。

我需要向上滚动列表视图,然后单击标题上的右键,会出现一个弹出窗口。如果我选择该弹出键盘上的文本文件,则会出现并且标题将像下面的屏幕截图一样向下移动。

<div data-role="page" id="page1" style="background: rgb(25,7,7); position:absolute;left:0px;height:100%;width:320px;background-repeat:no-repeat">
    <div data-role="header"  id="page1Header" data-tap-toggle="false" data-position="fixed" style="height:46px;background:rgb(25,7,7);top:-1px">
        <img src="Images/add_btn@2x.png" id="addCategory" class="muncul"  style="position:fixed;height:25px;width:25px;right:10px;top:7px;"/>
    </div>
    <div  data-role="content" >
          <ul data-role="listview"  id="listTable" class="mainList" style="border:none;margin-top:-15px"></ul>
    </div>
    <div id="target" data-position="fixed" data-scroll="false" style="background: url(Images/popup_bg.png) no-repeat;background-size: 167px 91px;margin-left:5px">
         <input type="text"  id="adddescriptionName"  placeholder="Enter Category Name"  style="background:rgba(218,218,218,1);height:32px;width:153px;margin-top:15px;border-radius: 3px;" />
         <img  id="addSaveButton" src="Images/save_btn@2x.png" style="width:154px;background-size: 154px 29px;margin-top:1px;" />
    </div>
</div>

【问题讨论】:

我们在哪里可以看到这一点? 您可以添加任何屏幕截图或一些示例或分享您的标题 css 和文本字段 css 样式 @hexafraction,所以如果提问者提供更多详细信息,我们将无法提供帮助?您可能在此处反转了您的布尔表达式。 @FrédéricHamidi Bah,又是我的愚蠢。 【参考方案1】:

您可以尝试将标题的位置设置为绝对而不是固定。

#page1Header
position:absolute !important;
top:0;
left:0;
right:0;

【讨论】:

如果我使用绝对,当我滚动列表视图时,标题也会随着列表视图向上滚动。

以上是关于当在 jquery 中触发文本字段 onfocus 事件时,标题不固定的主要内容,如果未能解决你的问题,请参考以下文章

JavaScript 使用jQuery OnChange OnFocus文本输入

点击/单击选择输入/文本框字段的内容

JS事件 失焦事件(onblur)onblur事件与onfocus是相对事件,当光标离开当前获得聚焦对象的时候,触发onblur事件,同时执行被调用的程序。

JavaScript:onblur与onfocus区别

如何使 jQuery 自动完成列表显示所有选项 onfocus 并在选择选项后隐藏?

当在文本字段中输入字段中的数据时,Flutter Firestore 显示文档 ID