0

点击输入时我不想隐藏。http://jsfiddle.net/bTHNh/1/

$("body").click(function() {
    $(".search-input").hide();
});


$("#search").click(function () {

    $(".search-input").toggle();

    event.stopPropagation();
});
4

1 回答 1

0
$(document).click(function (event) {
    //alert(event.target.className);
    if(event.target.className != 'search-input') {
        $(".search-input").hide();
    }
});


$("#search").click(function (event) {
    event.stopPropagation();
    $(".search-input").toggle();
});

http://jsfiddle.net/Cmacu/bTHNh/4/

于 2013-08-23T18:32:03.803 回答