लगता है मैं एक समारोह है:जावास्क्रिप्ट में मैं एक प्रोटोटाइप विधि को किसी अन्य प्रोटोटाइप विधि में कैसे कॉल कर सकता हूं?
function test(){}
test.prototype.method01=function(){
//do something
}
test.prototype.method02=function(){
//how can I call the method01?
//this.method01()...?
//but the chrome through an error:
//Uncaught TypeError: Object #<HTMLImageElement> has no method 'method01'
}
संपादित: वास्तव में इस तरह method01:
test.prototype.method02=function(){
$('.cpy').resizable({
}).draggable({
start:function(e,ui){
this.method01();
}
});
}
आप 'method02' एक छवि का एक घटना के लिए किसी भी संयोग से बताए रहे हैं? – pimvdb
यह * विधि * 2 पर कॉल * कैसे * पर निर्भर करता है। आपको [इस' के बारे में [एमडीएन लेख] पढ़ना चाहिए (https://developer.mozilla.org/en/JavaScript/Reference/Operators/this)। –
@pimvdb: मैंने अपना प्रश्न सुधार लिया है, दिखाएं कि मैं इसे कैसे कॉल करता हूं – hh54188