我找到这段代码来检测 android 原生浏览器:
var nua = navigator.userAgent;
var is_android = ((nua.indexOf('Mozilla/5.0') > -1 && nua.indexOf('Android ') > -1 && nua.indexOf('AppleWebKit') > -1) && !(nua.indexOf('Chrome') > -1));
但是如何在检测后创建函数来替换 css?
我知道我应该使用类似的东西:
$('jQuery selector').css({"css property name":"css property value"});
但我现在不知道如何:(
在同一页面上还有其他使用 jquery 的函数。
最佳答案
var nua = navigator.userAgent;
var is_android = ((nua.indexOf('Mozilla/5.0') > -1 && nua.indexOf('Android ') > -1 && nua.indexOf('AppleWebKit') > -1) && !(nua.indexOf('Chrome') > -1));
if (is_android){
//for eg you want to remove border of a div with id #container
$('#container').css({"border":"none"});
//Best is to have a class created in css with which ever property you want to remove
// if the class was .green-color
$('#container').removeClass('green-color');
}
关于javascript - 如何在用户代理检测后使用 jquery 替换 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34610671/