问答详情
源自:4-1 编程挑战

清除的选项怎么写函数?

我的代码段是写进去所有初始的样式(css里的),有没有简单的方法?

提问者:苍白的尾巴 2016-04-06 08:11

个回答

  • 小吴同志
    2016-04-06 09:26:37
    已采纳

    你定义函数的时候赋值就初始化函数了呀,css中是不存在函数的

  • 仁太
    2016-04-06 10:36:15

    removeAttribute('style')可以直接移除所有style属性

  • 小吴同志
    2016-04-06 10:18:08

    感觉你刚讲的和这个很像,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");

        }

        }


  • 小吴同志
    2016-04-06 09:01:36

    我的代码段是写进去所有初始的样式(css里的)?能说的更通俗一些么?

  • 苍白的尾巴
    2016-04-06 08:44:17

    这不是更长吗?还是要把每一个都要恢复设置。有没有更简单的方法?

  • 小吴同志
    2016-04-06 08:40:34

    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;
    }