我正在创建一个效果。当用户点击div检查时,它将滚动到#basket-page并显示,当用户点击外部时,#basket-page会隐藏。唯一的问题是,当用户点击第一次检查div时,#basket-page会立即显示并隐藏,如果我点击第二次或第三次,它没有问题。我能做些什么来解决这个问题。jquery滚动并点击div的外部并隐藏div?
jQuery(document).mouseup(function (e)
\t {
\t var container = jQuery("#basket-page");
\t if (!container.is(e.target) // if the target of the click isn't the container...
\t && container.has(e.target).length === 0) // ... nor a descendant of the container
\t {
\t container.fadeOut();
\t }
\t });
\t
\t jQuery('#checkout_top').click(function(){
\t \t var basket_page=jQuery('#basket-page');
\t \t jQuery('#top_basket').html(basket_page);
\t \t
\t \t var position = jQuery("#myshop_wrap").position();
\t \t scroll(0,position.top);
\t \t jQuery("#basket-page").show();
\t });
\t
<div id="#checkout_top">Check</div>
<div id="basket-page"></div>
这段代码为你做些什么? – Amit