Here's the fiddle.當我點擊打開它的鏈接時,爲什麼這個div不會關閉?
的代碼包括:
$('.icon').click(function() {
$('.foo').toggle();
});
$(document).mouseup(function (e) {
var container = $('.foo');
if (!container.is(e.target) // if the target of the click isn't the container...
&&
container.has(e.target).length === 0) // ... nor a descendant of the container
{
container.hide();
}
});
我可以使用鏈接來打開它,代碼關閉它,當一個點擊它的外面,但我不能打開它的鏈接關閉原來。
http://jsfiddle.net/gT5BT/104/ – rps