0
目前我有一个搜索图标,当它悬停在它上面时打开搜索框,当鼠标离开它时关闭搜索栏。但是我不明白如何在运行一次之前运行一次。如何阻止Jquery运行多次直到脚本完成
HTML
<div id="search-container">
<input type="submit" name="ctl00$btnSearch" value="Go" id="ctl00_btnSearch" class="trigger searchbutton search-bg">
<div class="search-bar">
<input name="ctl00$txtSearch" type="text" id="ctl00_txtSearch" class="searchbox" value="Search" onfocus="this.value=''">
</div>
</div>
的JavaScript
$(document).ready(function() {
$('#search-container .trigger').mouseover(function() {
$('section .search-bar input').animate({width:"150px"}, 750, function(){
$(this).find('input').first().focus();
});
$('.search-bar').animate({width:"185px"}, 750, function(){
$(this).find('input').first().focus();
});
$("#search-container .trigger").mouseleave(function(){
$("section .search-bar input, .search-bar").animate({width:"0px"}, 750, function(){
$(this).find('input').first().focus();
});
});
});
});
您的演示不会因为工作你有e未指定JQuery库。你还应该在你的问题 – musefan
中包含你的javascript,而你并没有导入Jquery,并且当你想让它出现在搜索框中,并且当你想让它消失时,并不清楚 –
“在再次运行它之前如何让它运行一次”。你的意思是,当页面加载?要么 ?? – TCHdvlp