prototype(2)
-
prototype.js 의 Object
$ 메소드 출처 : http://run2you.tistory.com/4 $ 메소드는 document.getElementById 의 축약형이라고만 생각할수도 있지만 그건 오산이예요~ $ 메소드를 사용하지 않을시 박스예요 ^^ 해당 div 를 javascript 로 hide 시키고 싶을시 var target = document.getElementById('box'); target.style.display = 'none'; 이렇게 써야 하죠 이걸 prototype.js 를 사용하여 $ 메소드를 쓴다면 $('box').hide(); 간단 하죠!! 단지 document.getElementById 의 축약형이라면 hide 메소드는 도대체 어디서 왔을까요~~ 그건 내부적으로 $ 메소드에서 target 이 되는 obj..
2012.07.24 -
javascript prototype 설명
prototype 이란 무엇이고 어떻게 써야 할건가 ? var man = function(name){ this.name = name; } var niceguy = new man('멋진인생'); alert(niceguy.name); 생성자 함수를 사용하여 객체를 하나 생성했습니다. 객체의 프로퍼티에 접근하기 위해선 상기 소스 처럼 사용해도 되나.. 우리는 인스턴스 메소드를 사용해서name 을 가져오는 getName 메소드를 만들어 보도록 할겁니다 var man = function(name){ this.name = name; this.getName = function(){ alert(this.name); } } var niceguy = new man('멋진인생'); niceguy.getName(); var ..
2011.01.11