this and that
by Matt Smith
HTML
<button id="blue" class="demo">
Blue
</button>
<button id="red" class="demo">
Red
</button>
CSS
#blue {
background-color: blue;
color: white;
margin: 5px;
font-size: 24px;
}
#red {
background-color: red;
color: white;
margin: 5px;
font-size: 24px;
}
JavaScript
class Player {
constructor(){
$(".demo").click(function() {
console.log(this)
console.log($(this).text())
}.bind(this));
this.color
this.name = 'Player 1'
}
printName(player){
if(player == 1)
console.log(this.name + "'s color is " + this.color)
}
}
let me = new Player();