苍白的尾巴
2016-04-06 08:11
我的代码段是写进去所有初始的样式(css里的),有没有简单的方法?
你定义函数的时候赋值就初始化函数了呀,css中是不存在函数的
removeAttribute('style')可以直接移除所有style属性
感觉你刚讲的和这个很像,js里的removeAttribute()方法可以删除初始属性~
code如下:
//定义"取消设置"的函数
function cancle(){
if(confirm("是否继续?")){
// txt.style.width="600px";
// txt.style.heightr="400px";
// txt.style.color="#000";
// txt.style.background="#fff";
txt.removeAttribute("style");
}
}
我的代码段是写进去所有初始的样式(css里的)?能说的更通俗一些么?
这不是更长吗?还是要把每一个都要恢复设置。有没有更简单的方法?
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,p {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
}
JavaScript入门篇
740353 学习 · 9566 问题
相似问题