JSFiddle - React, Tailwind, and code Playground
by Manpreet Singh
HTML
<div id = "demo">
Test
</div>
JavaScript
function Test()
{
}
Test.prototype.init = function()
{
this.test ="hello"
window.addEventListener('orientationchange', this.doOnOrientationChange);
}
Test.prototype.doOnOrientationChange = function() {
var demoElem = document.getElementById("demo");
switch(window.orientation) {
case -90 || 90:
alert('landscape' + demoElem.textContent);
console.log("landscape");
break;
default:
alert('portrait'+ demoElem.textContent );
console.log("portrait");
break;
}
}
// Initial execution if needed
//doOnOrientationChange();
var t = new Test()
t.init()