간단한 알림 시스템을 작성하고 있지만 JS/jQuery (프론트 엔드는 새로운 기능)를 학습하고 있으며 문제가 있습니다.JS/jQuery 객체
(function ($) {
var notification = function(title, msg, duration) {
this.element = $('<div class="notification"><h3>' + title + '</h3><div class="notification_body">' + msg + '<br/><i>(для скрытия уведомления кликните здесь два раза)</i></div></div>');
this.element.dblclick(notification.hide);
$('#notifications_bar').prepend(this.element.hide().fadeIn(1000));
}
notification.hide = function() {
var $this = this;
this.element.fadeOut(1000, function() {
$this.element.remove();
})
}
$.extend({
notify: function(title, msg, duration) {
return new notification(title, msg, duration);
}
});
})
(jQuery);
을하지만 방법 notification.hide
에 오류가 있습니다 : 나는 다음 코드 작성 this.element
가 정의되어 있지 않습니다. 어디에서 오류를 설명 할 수 있습니까? 감사합니다.
이 너무 html 코드를 공유 할 수 있습니다 –
톤를? 그의 "notification.prototype.hide = function() {"이 더 좋고 메모리 효율적인 방법입니다. "notification.hide = function() {", 원래 문제에 대한 대답은 아래에서 Matt – Ankit