我試圖在我的頁面上的特定 div 中向用戶顯示他們的螢屏解析度。我已經用一個按鈕和一個alert:
function getResolution() {
alert("Your screen resolution is: " Math.floor(screen.width * window.devicePixelRatio) "x" Math.floor(screen.height * window.devicePixelRatio));}
但我希望它只顯示在 div 中,而不是使用按鈕和警報。我試過的:
$(function(){
$('#info').show("Your screen resolution is: " Math.floor(screen.width * window.devicePixelRatio) "x" Math.floor(screen.height * window.devicePixelRatio));
});
uj5u.com熱心網友回復:
$('#info')).show()
如果你想設定內容,這段代碼會讓#info顯示,試試這個:
$('#info').text("Your screen resolution is: " Math.floor(screen.width * window.devicePixelRatio) "x" Math.floor(screen.height * window.devicePixelRatio))
檢查#info z-index 比其他的大
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/446097.html
標籤:jQuery
上一篇:為類函式中的引數設定條件
