0

Ex: On click of button, In desktop version screens it should display prompt message as ' Hi'. . same on click in mobile screen sizes it should display prompt message as "Hello".

2 Answers2

0

Check this answer out. Then after getting the width of your screen you can

getElementById("my_element").innerHTML() and set whatever you want to.

Community
  • 1
  • 1
catchiecop
  • 388
  • 6
  • 24
0

You could do something like this:

var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;

$('#btn').on('click', function() {
  if (width > 480 && height > 800) {
    alert('hi');
  } else {
    alert('hello');
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" id="btn" value="Click me" />
Calum
  • 1,889
  • 2
  • 18
  • 36