所以我here如果浏览器支持 HTML5,我可以使用这样的代码来更新 CSS:
$(":header").append('<style type="text/css"> body { background-color: rgb(200,200,200); margin: 0px; overflow: hidden; font: 100.01% "Trebuchet MS",Verdana,Arial,sans-serif; } #info { position: absolute; top: 0px; width: 100%; color: #ffffff; font-family:Monospace;font-size:13px; font-weight: bold; position:absolute; height:100%; overflow:auto; } a { color: #ffffff;} h1,h2,p{margin: 0 10px} h1{font-size: 250%;color: #FFF; text-shadow:0px 1px 1px #000;} h2{font-size: 200%;color: #f0f0f0;padding-top: 0.3em}div#nifty{ margin: 0 10%;background: rgba(250, 250, 250, 0.1); -moz-border-radius:15px; border-radius: 15px;} b.rtop, b.rbottom{display:block;background:#FFF; } b.rtop b, b.rbottom b{display:block;height: 1px;overflow: hidden; background: #9BD1FA} b.r1{margin: 0 5px} b.r2{margin: 0 3px} b.r3{margin:0 2px} b.rtop b.r4, b.rbottom b.r4{margin: 0 1px;height: 2px} p, ul{color:#000;text-shadow: 0px 1px 1px rgba(255,255,255,0.6);padding-bottom:1em}input[type="button"], .eButton {width: 150px;padding: 5px 10px;word-wrap:break-word;height: auto;} b.rtop, b.rbottom{display:none;background: rgba(0,0,0,0)}html{ width:100%; height:100%; min-width:900; min-height:700;} body{ width:100%; height:100%; } #container{ width:100%; height:100%;} </style>');
我的背景是 3D 天空。
当 EEE PC 到来时(即使是最新的 chrome beta),他也会出现在我的 Hi-ReS 页面上!统计数据 <= 4 fps。所以我需要对 jQuery 函数进行某种 UnDo - 清除添加到页面的内容。怎么做这样的事情?
最佳答案
为什么不向主体添加一个类,并通过该类让所有魔法发生?
示例:
(在您进行测试以检查它是否支持 html5 之后)
$("body").addClass("html5Supported");
还有 CSS(将其添加到您的 CSS 文件中):
.html5Supported {
background-color: rgb(200,200,200);
margin: 0px;
overflow: hidden;
font: 100.01% "Trebuchet MS", Verdana, Arial, sans-serif;
}
.html5Supported #info {
position: absolute;
top: 0px;
width: 100%;
color: #ffffff;
font-family: Monospace;
font-size: 13px;
font-weight: bold;
position: absolute;
height: 100%;
overflow: auto;
}
(您想要更改的其余部分也是如此)。
如果您想“撤消”它,只需将其删除即可:
$("body").removeClass("html5Supported");
在我看来,这种方法比查找您附加的样式更好,而且与内联版本相比,您可以更好地控制 CSS。
关于javascript - jQuery - 如何创建可撤消的操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5530673/