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>

  • 相关阅读:
    android 设置状态栏与标题背景颜色一致
    Android 无标题、全屏设置
    android Activity绑定Service
    lua入门之四元表
    lua入门之三module
    lua入门之二table
    lua入门之一函数
    Cocos2dx 3.10版编译安卓报卷标错误
    js 创建、添加、删除元素节点 添加文本节点
    正则表达式
  • 原文地址:https://www.cnblogs.com/duanlinlin/p/3029149.html
Copyright © 2011-2022 走看看