JSFiddle - React, Tailwind, and code Playground
by webnotes42
HTML
<p id="ex1"><b>myCountry.getCapital() : </b></p>
<p id="ex2"><b>myCountry.myName : </b></p>
<p id="ex3"><b>actor1.name : </b></p>
<p id="ex4"><b>actor2.age : </b></p>
<input type="button" value="show result">
JavaScript
var myCountry = {
getCapital: function() {
$("#ex1").append(this.myCapital);
//if you want to use javascript
//please uncomment this code
//alert(this.myCapital);
},
myName: 'USA',
myCapital: 'Washington DC'
}
function myPerson(a, b) {
this.name = a;
this.age = b;
}
var actor1 = new myPerson('Jack', '42');
var actor2 = new myPerson('Mary', '33');
$(function() {
$(":button").click(function() {
$("#ex1").append(myCountry.getCapital());
$("#ex2").append(myCountry.myName);
$("#ex3").append(actor1.name);
$("#ex4").append(actor2.age);
});
});
/*
//if you want to use javascript
//please uncomment this code
myCountry.getCapital();
alert(myCountry.myName);
alert(actor1.name);
alert(actor2.age);
*/