替换输入字段的文本会移动其位置
Replacing text of input field moves its location
>我有一个由某些事件控制的搜索表单,当它模糊时,该函数会检查值是否为空,如果是,它会将默认搜索文本放回原位。
下面是指向示例页面的链接:http://merkd.com/community
以下是相关功能:
// searchInput is a jQuery reference to the <input> field
// searchTextColor is the original font color of the unfocused form
// searchText is the original search text
$('#header form').on('blur', 'input', function() {
searchInput.css('color', searchTextColor);
// When I comment these lines out, it doesn't move
if ( searchInput.val() == '' ) {
searchInput.val(searchText);
}
});
要查看故障,请在搜索字段中键入一些文本,然后将其删除并模糊搜索表单,输入字段将向左移动。
知道为什么会这样吗?就像我说的,如果我不更改文本,那么它就不会移动。我不知道这会如何影响元素在页面中的位置。
问题
这是发生的,这就是问题发生的原因
见萤火虫
<input type="text" value="Search Teams, Players, Etc." name="search">
<img title="Search" alt="Search" src="/engine/themes/img/search.white.focus.png">
<input type="submit" value="Search Teams, Players, Etc.">
溶液
$('#header form').on('blur', 'input[name=search]', function() {// not use input other wise valuse also set in submit input box
searchInput.css('color', searchTextColor);
// When I comment these lines out, it doesn't move
if ( $(this).val() == '' ) {
$(this).val(searchText);
}
});
相关文章:
- 在不移动元件的情况下从相对位置更改为固定位置
- 如何在鼠标悬停时将对象从起始位置移动到结束位置,然后在鼠标悬停后再次移动
- 将插入符号位置移动到ContentEditable<DIV>
- 我发现了一些只在移动设备上可见的垃圾邮件链接,我可以'找不到包含此垃圾邮件链接的脚本的位置
- float's未返回到移动视图结束后的位置
- 将javascript数组中的项移动到特定位置的有效方法
- 如何将节点移动到所需位置
- Photoshop脚本:将图像移动到位置x,y
- 在鼠标上触发鼠标移动'的当前位置
- 固定图像滚动移动位置
- Javascript滚动和移动位置
- 如何确保按钮点击均匀移动位置
- 当地图移动时,必应地图InfoBox会在FireFox和Chrome中移动位置
- 当尝试按下鼠标选择所有对象时,对象会自动移动位置(Fabric.JS)
- 在必应地图上获取移动位置
- 精灵图像的随机移动位置
- 如何将多个标记添加到移动位置谷歌地图,Javascript
- 创建用于移动位置的常量而不是变量
- 如何根据鼠标移动/位置应用效果
- MediaWiki我如何得到[折叠]链接不移动位置与文本