zoukankan      html  css  js  c++  java
  • jQuery设置页面样式

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <style type="text/css">
        p
        {
            background-color:#eee; font-size:30px;
            }
            .classadd
            {
                font-weight:bold; font-family:微软雅黑; font-size:40px; background-color:Green;
                }
                .classadd1
                {
                    background-color:Red;
                    }
        </style>
        <script src="jquery-1.9.1.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function () {
                $('#btnclass').click(function () {
                    $('p').css('background-color', 'blue');//设置样式
                })
                $('#btnAdd').click(function () {
                    $('p').addClass('classadd classadd1');//添加样式
                })
                $('#btnRemove').click(function () {
                    $('p').removeClass('classadd1'); //删除指定名称的样式
                })
                $('#btnChange').click(function () {
                    $('p').toggleClass('classadd1');
                })
            })
        </script>
    </head>
    <body>
    <p class="classadd">得用汉字</p>
    <input type="button" id="btnclass" value="设置样式" />
    <input type="button" id="btnAdd" value="添加样式" />
    <input type="button" id="btnRemove" value="删除样式" />
    <input type="button" id="btnChange" value="切换样式" />
    </body>
    </html>

  • 相关阅读:
    如何配置mysql的超时时间
    什么是P2P流标
    为何农历10月1号要祭祖上坟?原来有这么多讲究,你知道吗?
    “请家堂”的旧习俗不是封建迷信
    sourcetree合并分支
    mybatis sql参考
    source tree使用经验
    关于 early Z 与 z-prepass
    发现一个好工具RenderDoc
    HASHSET不能预留容量问题
  • 原文地址:https://www.cnblogs.com/duanlinlin/p/3029149.html
Copyright © 2011-2022 走看看