호출시 이벤트로드를 허용하도록 플러그인을 수정하려면 어떻게해야합니까? 지금은 페이지가로드 될 때 플러그인이로드되며 .blur() 또는 대신 할당 할 이벤트가 필요합니다. 어떤 도움을 주시면 감사하겠습니다 : 그것은) (흐림에 작동하지 않습니다jQuery의 사용자 정의 플러그인 기능에 이벤트 바인드
// The Plugin
(function($) {
$.fn.required = function() {
return this.each(function() {
var $this = $(this), $li = $this.closest("li");
if(!$this.val() || $this.val() == "- Select One -") {
console.log('test');
if (!$this.next(".validationError").length) {
$li.addClass("errorBg");
$this.after('<span class="validationError">err msg</span>');
}
} else if($this.val() && /required/.test($this.next().text()) === true) {
$li.removeClass("errorBg");
$this.next().remove();
}
});
}
})(jQuery);
// The Event Call
$("[name$='_required']").required().blur();
, 그 대신 .blur() 이벤트의 문서로드에 플러그인을 트리거합니다.