通过“oncklick”功能获得了名为“notebutt”的按钮
功能很简单,用户点击按钮,div为fadeIn(),再次点击,div必须fadeout();
notebutt.bind("click", function () {
var notediv = $(this).parent().find("div.notediv");
// checking is notediv exist already, if not, creating one and do fadeIn(150);
if (!notediv) {
notediv = $('<div class="notediv" contenteditable="true"></div>');
notediv.appendTo($(this).parent());
notediv.offset({top: posT-47}).fadeIn(150);
} else {
// if got notediv created before, i must show or hide it with hideorshow(notediv);
hideorshow(notediv);
}
});
// func that check's is div was showned or not
function hideorshow(div){
if ($(div).is(':visible')) {
//hide if visible
div.fadeOut();
} else {
div.offset({top: posT-47});
div.fadeIn();
}
};
乍一看,它应该像应该的那样工作,但是在按钮上点击 5-10 次后都出错了,div 在点击时随机闪烁,就像 fadeIn 和 fadeOut 同时运行一样,或者彼此有什么方法可以进行一些适当的触发检查 div 状态?