DOM 요소를 모두 확장하지 않고 확장하고 싶습니다. 즉, 자체 메서드 및 속성을 가진 사용자 지정 클래스를 원하지만 div로 처리 할 수도 있습니다. 예 :jQuery로 DOM 요소 확장하기
MyClass = function(){
this.foo = "waaa";
}
MyClass.prototype.changeText = function(newtext){
// if this extended $(document.createElement("div")) something
// like this might be possible
this.html(newtext);
}
MyClass.prototype.alertFoo = function(){
alert(this.foo);
}
var m = new MyClass();
$("body").append(m);
m.changetext();
이것은 가능합니까?
이것은 플러그인을 확장 할 때도 유용합니다. 따라서 this.hide가 실제로 this.fadeOut이되도록 함수를 재정의하십시오. 클래스 내부에서 __proto__를 사용하고 다음과 같이 기본 jquery 객체를 전달합니다. [link] (http://pastebin.com/hFUnqTBQ) – Shanimal