如果您單擊紅色塊顯示的頂部輸入。我怎樣才能阻止它,當你點擊紅色塊或其輸入,然後塊隱藏。我的代碼只適用於Chrome,但不適用於Firefox或ie。可以請你幫如何停止模糊關閉塊
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="js/libs/jquery-1.8.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var $txtMain = $('#txtMain');
var $popupInput = $('#popupInput');
var $popup = $('#popup');
$popup.hide();
$txtMain.focus(function() {$popup.show();});
$popupInput.focus(function() {$popup.show();});
$popup.focus(function() {$popup.show();});
$txtMain.blur(function() {$popup.hide();});
$popupInput.blur(function() {$popup.hide();});
$popup.blur(function() {$popup.hide();});
});
</script>
</head>
<body>
<br /><br />
<input type="text" id="txtMain" />
<div id="popup" style="width: 200px; height: 200px; background: none repeat scroll 0% 0% red;" tabindex="5"><br /><br />
<input type="text" id="popupInput">
</div>
<br /><br />
<br /><br />
<br /><br />
<br /><br />
<br /><br />
<br /><br />
<br /><br />
<input type="text" id="test" />
</body>
</html>
在Firefox中,當您點擊$ popupInput時,您首先會對剛剛離開的任何輸入發出模糊處理,以便隱藏。這可以防止重點放在$ popupInput上。或者說,它可能會引發新元素的焦點,然後模糊舊元素 – ediblecode
你自己的問題的重複[div沒有得到及時的焦點:模糊在焦點之前觸發](http://stackoverflow.com/questions/19270504/div-is-not-getting-focus-in-time-blur-fires-the-the-focus-out) – CBroe
我從來沒有得到答案 –