鼠标悬停并Mouseout 与输入字段的 jQuery 问题
旧代码
当我越过“#search”div然后它像我应该做的那样滑动它时遇到了问题,但问题是当它滑出时它会显示一个搜索输入字段,当鼠标滑出时它会显示一个搜索输入字段越过该输入字段,它开始运行鼠标移出功能,我通过将鼠标悬停在带有空函数的 #search 输入上来停止此操作,但是当我的鼠标离开输入和“#search”潜水时,它不会运行动画返回功能。
这是我的脚本
$("#search").mouseover(function(){
$(this).animate({"left": "0px"}, 500);
});
$("#search").mouseout(function(){
if($("#search input").mouseover()){
return false
}
else {
$(this).animate({"left": "-282px"}, 500);
}
});
我做错了什么?或者有人有解决办法吗?我是 jQuery 的新手,所以刚刚开始学习:),我在过去 2 天搜索了 Google 和文档,也许只有我是盲目的,这就是为什么我需要你的帮助:
编辑:新代码 & JS FIDDLE
我需要对搜索栏进行不同的操作,所以我只是再次编写了代码,现在需要单击该语句。看这里 JSfiddle
这就是我想要的 jQuery创造 :)
OLD CODE
I got a problem when I over my "#search" div then it slides it like I should do, bur the problem is when it slides out it reveals a search input field, and when the mouse gets over that input field it starts to run the mouse out function, I've stopped this by giving a if mouse over #search input with a empty function but when my mouse leaves the input AND the "#search" dive it wont run the animate back function.
Here's my script
$("#search").mouseover(function(){
$(this).animate({"left": "0px"}, 500);
});
$("#search").mouseout(function(){
if($("#search input").mouseover()){
return false
}
else {
$(this).animate({"left": "-282px"}, 500);
}
});
What do I do wrong? Or do anyone have a solution? I'm new to jQuery so just started learning :) and I've searched Google and the documentation for last 2 days, maybe its just me that's blind, that's why I need your help :
EDIT: NEW CODE & JS FIDDLE
I need to do the search bar different so I just made the code again now the statement needs to be clicked instead. Look here at JSfiddle
That's the jQuery I wanted to create :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试在将鼠标悬停在输入上时停止传播:
#search div 的常规代码应该可以正常运行。
Try stopping propagation when hovering the input:
Your regular code for the #search div should then function normally.