'jQuery get data to a div
I'm trying to show users their screen resolution in a specific div on my page. I've got it working with a button and an alert:
function getResolution() {
alert("Your screen resolution is: " + Math.floor(screen.width * window.devicePixelRatio) + "x" + Math.floor(screen.height * window.devicePixelRatio));}
But I want that to just show up in a div instead of using a button and alert. What I've tried:
$(function(){
$('#info').show("Your screen resolution is: " + Math.floor(screen.width * window.devicePixelRatio) + "x" + Math.floor(screen.height * window.devicePixelRatio));
});
Solution 1:[1]
$('#info').show()
this code will let #info display if you want to set content, try this:
$('#info').text("Your screen resolution is: " + Math.floor(screen.width * window.devicePixelRatio) + "x" + Math.floor(screen.height * window.devicePixelRatio))
check #info z-index is bigger than others
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ruleboy21 |
