判断是否是手机端

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Show/Hide Element Based on Screen Size</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>

<div class="mobile-only hidden">
This is the content to be shown only on mobile.
</div>

<script>
$(document).ready(function(){
// 判断屏幕宽度
function checkScreenWidth() {
if ($(window).width() < 768) {
$(".mobile-only").show();
} else {
$(".mobile-only").hide();
}
}

// 页面加载时检测屏幕宽度
checkScreenWidth();

// 窗口大小改变时重新检测屏幕宽度
$(window).resize(function() {
checkScreenWidth();
});
});
</script>

</body>
</html>