Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这不起作用
if( $.browser.opera ){ $("body").addClass('opera'); }
为什么?
你有没有尝试过
if( $.browser.opera ){ $("body").attr("class", "opera"); }
使用 addClass 没有问题。当我查看源代码时加载歌剧时,正文中没有“歌剧”类,但是当我添加 CSS body.opera{display:none;} 时,它会被执行。所以问题出在浏览器上。浏览器不会对用户可见的浏览器源代码进行 jQuery 更改。