【问题标题】:How to remove both the inline as well as written is css file in moovweb?如何删除 moovweb 中的内联和写入的 css 文件?
【发布时间】:2014-12-02 20:05:10
【问题描述】:

我想删除应用于特定 div 的内联和外部 css。

我不想使用 remove_all_styles() 来删除页面的所有样式。

我怎样才能做到这一点?

【问题讨论】:

    标签: jquery moovweb


    【解决方案1】:

    删除样式和类属性是否有效?

    $("#ParticularDiv").removeAttr("class").removeAttr("style");
    

    【讨论】:

      【解决方案2】:

      你可以试试;

      $("#div"){
          remove_attributes()
      }
      

      那么你就会有一张白纸。

      【讨论】:

        【解决方案3】:

        删除特定 div 的内联 css

        $('#div_id').removeAttr('style');
        

        或者你也可以在你的css中使用not属性。

        在html中:

        <button class="nostyle">
        

        在css中:

        button:not(.nostyle) {
        

        Usefull fiddle by Danny Beckett

        【讨论】:

          【解决方案4】:

          您可以通过使用 tritium 选择 div 然后使用 attribute(...) 函数清除 style 属性来做到这一点。假设我有以下 html:

          <html>
            <body>
              <div style="background: red">Hi</div>
            </body>
          </html>
          

          我可以编写以下氚来删除内联样式:

          $("/html/body/div") {
            attribute("style", "")
          }
          

          一个捷径是使用氚中的remove(...) 函数。借助一些 XPath 魔法,您可以将上面的代码变成这样的单行代码:

          remove("/html/body/div/@style")
          

          这应该会删除与 div 关联的内联样式。

          【讨论】:

            【解决方案5】:

            您可以通过 $('#div') {remove_atributes()} 将其删除,这将删除 div 中的所有属性,否则您可以使用 remove_class('ClassName') 删除包含样式的类

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2018-04-15
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2015-02-07
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多