gpt4 book ai didi

javascript - UC mini浏览器如何只显示一个div?

转载 作者:行者123 更新时间:2023-11-29 23:57:56 24 4
gpt4 key购买 nike

下面是一个简单的标记。谁能帮我写一个脚本,该脚本仅在 uc mini 浏览器中显示带有“信息框”类的 div。它应该隐藏在浏览器的其余部分。

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>UC Mini</title>
</head>
<style>
.info-box {
display:none;
}
</style>
<body>
<div class="info-box">My content here</div>
</body>
</html>

最佳答案

试试这个:

CSS:

.info-box {
display: none;
}

jQuery:

if (navigator.userAgent.match(/^Mozilla\/5\.0 .+ Gecko\/$/)) {
$(".info-box").show();
}
else {
$(".info-box").hide();
}

虽然这可行,但大多数情况下不推荐这样做。您应该关注更通用的方法。

关于javascript - UC mini浏览器如何只显示一个div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41276203/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com