我有一个效果,当单击一个按钮时,html / span会滑出。这项工作很好。然后,当我希望用户单击按钮或html / span之外时,html / span将隐藏。隐藏部分也起作用,但是当我再次尝试该过程时,我必须双击按钮以显示幻灯片效果。我怀疑我的命令有误或其他...有人可以帮助我吗?
$(document.body).ready(function () {
$(".comment_function").on("click", function () {
$(".comment_confirm").show(400,"linear");
});
$(document.body).on("click", function () {
if (!$(".comment_function").closest(".comment_confirm").length) {
if ($(".comment_confirm").is(":visible") ) {
$(".comment_confirm").hide();
}
}
});
});
不知道为什么这些代码不能在小提琴中工作,但它与我现在的小提琴非常接近
只需侦听from中的点击事件,document
然后检查单击的元素是否为.one
。如果是,则显示.two
否则将其隐藏。
$(document).on('click', function (e) {
var t = $(e.target);
if (t.hasClass('one')) {
$('.two').show(400, 'linear');
} else {
$('.two').hide();
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句