日期:2014-05-18  浏览次数:20391 次

jquery控制显示与隐藏
是这样的.
页面中的js

用jquery的方法 $("#div1").load("aa.aspx");
加载了个页面,,放到div1中

html代码如下:

<input type="text" id="txtTo" name="txtTo">
<div id="div1">

</div>

js代码:
$("#txtTo").focus(function () {
  $("#div1").load("aa.aspx");
});

现在想实现当鼠标 不在 txtTo文本框中,不在<div>所包围中,去隐藏掉<div>...js代码如何写?谢谢!



------解决方案--------------------
<input type="text" id="txtTo" name="txtTo" onblur='$("#div1").hide();'>
------解决方案--------------------
JScript code

$(function(){
$("div").mouseleave(function () {
  $(this).hide();
});

})

------解决方案--------------------
JScript code
jQuery(function($) {
            $('#txtTo').mouseout(function() {
                var i = false;
                $('#div1').hover(function() {
                    i = true;
                    $(this).show();
                }, function() {
                    $(this).fadeOut(1000);
                });
                if (i == false) $('#div1').hide();
            }).mouseover(function() {
                $('#div1').show();
            });
        });