您当前的位置: 首页 >  jquery

[JQ权威指南]第二天:JQuery控制CSS样式

发布时间:2015-06-10 08:37:41 ,浏览量:0

在页面中,增加一个

元素标记,用户单击该元素时,变换其字体和背景颜色,再次单击时,恢复其初始的字体和背景色。
 <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JQuery事件的链式写法title> <script type="text/javascript" src="jquery-2.1.4.js">script> <style type="text/css" > .iframe{ border:soild 1px #888; font-size:13px;} .defcol{ padding:8px; background-color:#eee;} .curcol{ padding:8px; background-color:#ccc; color:#fff } style> <script type="text/javascript"> $(function(){ $(".defcol").click(function(){ $(this).toggleClass("curcol");
             })
         }) script> head> <body> <div class="iframe"> <div class="defcol">标题div> div> body> html> 

原始 效果

关注
打赏
1688896170
查看更多评论

暂无认证

  • 0浏览

    0关注

    105695博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0732s