html - 将 <style> block 设置为禁用

标签 html css

如何禁用样式 block ?

<style disabled="true">
    progress {
        background-color: rebeccapurple;
        border: 0;
        border-radius: 9px;
        height:25px;
        width:300px;
    }
</style>

上面好像不行,请问这样可以吗?还是我需要以编程方式禁用它?

最佳答案

试试这个:

 <style id="switch">
 body{ 
    background-color: gray;
 }
 </style>

 <script>
 $(document).ready(function(){
     $('.button').click(function(){
        document.getElementById("switch").disabled=true;
    });
 });
 </script>

<html>
    <body>
    <a href="#" class="button"><button>Button</button></a>
    </body>
</html>

给style标签设置一个id会控制特定的css。您可以通过将 disabled 改回 false 来重新启用它。希望有用。

关于html - 将 &lt;style&gt; block 设置为禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36048065/

相关文章:

html - 内部所有内容周围的 div 的背景颜色

javascript - 在触发日历单击事件之前,div 标记内的 JQuery 完整日历不会显示

javascript - 如何为表格应用水平滚动条

jquery - 调整 div 的大小以适应最大高度的内容

html - 当包含 bootstrap 时,使用背景颜色创建的边框会消失

选择时的 jQuery 过滤器

jquery - 向 css 类添加不透明度

php - 构建这个复杂图的最佳方法是什么

html - 如何在 tumblr 主题上设置 block 引用样式?

jquery - 居中对齐面板并使用 bootstrap 和 css 更改其标题和主体颜色