博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jQuery设置页面样式
阅读量:7053 次
发布时间:2019-06-28

本文共 1090 字,大约阅读时间需要 3 分钟。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<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>

转载于:https://www.cnblogs.com/duanlinlin/archive/2013/04/18/3029149.html

你可能感兴趣的文章
Spring MVC之@RequestMapping 详解
查看>>
使用STS和Gradle创建Restful服务-Hello World
查看>>
网络服务器开发总结
查看>>
关于redis的主从、哨兵、集群
查看>>
Extjs Form用法详解
查看>>
ExecutorService线程池
查看>>
OD使用及快捷键
查看>>
将Mule ESB Http项目转换为Tomcat项目(3) ESB项目运行
查看>>
IE9开始支持SVG格式(VML终结)
查看>>
php set_time_limit
查看>>
一种Android的多平台的安装包打包方法探究
查看>>
观察者模式
查看>>
【转】PHP中的Hash算法
查看>>
SqlLite的工具类SQLiteOpenHelper
查看>>
chgrp chown chmod
查看>>
nodejs中安装express
查看>>
2014软件表
查看>>
Struts2教程3:struts.xml常用配置解析
查看>>
(转帖)Implementing custom JavaFx Bindings
查看>>
mysql外键
查看>>