Setting Events in a class that utilize a later mentioned Prototype?

244
November 26, 2017, at 10:30 PM

When I reach the console.log() its returning window.

How can I get the element under consideration?

let builder = function(){
    this.box = $(`<div id="box" class="box">`);
    this.inputcontainer = $(`<div id="inputcontainer" class="inputcontainer">`).appendTo(this.box);
    this.textarea = $(`<textarea id="textarea"></textarea>`).appendTo(this.inputcontainer);
    this.textarea.on("change keyup keydown input paste", this.postmsg);
    this.chat.appendTo($('body'));
}
//someothercode
builder.prototype.postmsg = (e) => {
    console.log(this); // returns window when i need it to be referencing textarea
}
let instance = new builder();
Answer 1
builder.prototype.postmsg = function(e){
    console.log(this.textarea);
}
Rent Charter Buses Company
READ ALSO
Which &ldquo;href&rdquo; value should I use for JavaScript links, &ldquo;#&rdquo; or &ldquo;javascript:void(0)&rdquo;?

Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?

The following are two methods of building a link that has the sole purpose of running JavaScript codeWhich is better, in terms of functionality, page load speed, validation purposes, etc

241
angular 4 observable returns [object Object]

angular 4 observable returns [object Object]

I am using Angular 4 as my frontend and Laravel 55 as my restful API

615
How to use imacros to reload recaptcha frame to load new captcha?

How to use imacros to reload recaptcha frame to load new captcha?

I need to use imacros to reload recaptcha frame in this image to load new captcha, everyone, plz help: Link to the captcha: https://wwwmytrainerrewards

342
Javascript: Changing a boolean in an else if statement

Javascript: Changing a boolean in an else if statement

i am having the following problemI am trying to do this but it is not working:

245