jquery 和 js css里面都是坑呀 this.style.backgroundColor 和 css {background:#8df;} 是冲突的,用了前者,再$(this).addClass("css class name");效果显示不出来。

http://youchenglin.iteye.com/blog/685026

前他的一些内容参见下列代码

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>a.html</title>
<style type="text/css">
div.content {
width: 300px;
border: 1px solid red;
} .divbox{
height:300px;
width:200px;
background:#ffffff;
border:solid 1px #ccc;
float:left;
margin-right:10px;
}
.divOver{
background:#eff8fe;
border:solid 1px #d2dce3;
} </style>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script> <script type="text/javascript">
jQuery (function ()
{
$ ("div.content").click (function ()
{
var $self = $ (this).attr ("id");
var $check = $ ("input#inputid" + $self);
if (!!$check.prop ("checked"))
{
$check.prop ("checked", false);
$ (this).css (
{
"color" : "black"
});
}
else
{
$check.prop ("checked", true);
$ (this).css (
{
"color" : "red"
});
}
}); $(".color").find("tr").each(function(i){this.style.backgroundColor=['#fff','#eee'][i%2]});//一行为白色,一行为灰色 $(".color").find("tr").mouseover(function(){
$(this).css("backgroundColor","#6699CC");
}); $(".color").find("tr").mouseout(function(){
$("tr:even").css("backgroundColor","#fff"); //偶数行的颜色
$("tr:odd").css("backgroundColor","#eee"); //奇数行的颜色
}); //当鼠标滑入时将div的class换成divOver
$('.divbox').hover(function(){
$(this).addClass('divOver');
},function(){
//鼠标离开时移除divOver样式
$(this).removeClass('divOver');
}
); });
</script>
</head>
<body>
<center> <input id="inputid1" type="checkbox" />aa<div class="content" id="1">1111</div>
<div id="results">11</div>
<div id="results2">23</div> <table width="200" border="0" cellspacing="1" bgcolor="#eeeeee" class="color">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<br/><hr/><br/>
</center>
<div id="menu">
<div class="divbox">区块A</div>
<div class="divbox">区块B</div>
<div class="divbox">区块C</div>
</div>
</body>
</html>

jQuery学习记录1的更多相关文章

  1. jquery学习记录

    1.选择器实例 语法 描述 $(this) 当前 HTML 元素 $("p") 所有 <p> 元素 $("p.intro") 所有 class=&q ...

  2. 2016.8.16 JQuery学习记录

    1.$(document).ready(function(){}); 这个函数会在浏览器加载完页面之后,尽快执行: 2.所有的JQuery函数用有个$开始表示,All jQuery functions ...

  3. jQuery Moblile Demos学习记录Theming、Button、Icons图标,脑子真的不好使。

    jQuery Moblile Demos学习记录Theming.Button.Icons图标,脑子真的不好使. 06. 二 / Jquery Mobile 前端 / 没有评论   本文来源于www.i ...

  4. jQuery Moblile Demos学习记录Panel

    jQuery Moblile Demos学习记录Panel 11. 二 / Jquery Mobile / 没有评论   本文来源于www.ifyao.com禁止转载!www.ifyao.com 我就 ...

  5. 【jQuery】精细学习记录

    [jQuery]精细学习记录 基础 基本语法: $(选择器).action(回调函数); $/jQuery //jQuery核心函数 $(选择器) //获得的jQuery对象 jQuery核心 - j ...

  6. D3.js学习记录【转】【新】

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. JQuery学习笔记——基础选择器

    第一篇博客,现在原生安卓需求不大了.招聘的Android工程师都需要附带更多的其他技术.这也是开启我学习前端之路的开端.前端时间看了HTML.CSS等,在界面渲染这一块,就不多记录博客了.现在学习着J ...

  8. Echarts学习记录——如何去掉网格线及网格区域颜色

    关键属性 splitLine和splitArea,可以设置相关的属性 示例代码 <!DOCTYPE html> <html lang="en"> <h ...

  9. Echarts学习记录——如何给x轴文字标签添加事件

    Echarts学习记录——如何给x轴文字标签添加事件 关键属性 axisLabel下属性clickable:true 并给图表添加单击事件 根据返回值判断点击的是哪里 感觉自己的方法有点变扭,有更好办 ...

随机推荐

  1. 透过数据看现实,漫谈实况FIFA的这些年

    虽然,只是个普通玩家,虽然带了一点青春,一点爱.虽然,有那么些怀念 ~ 好吧,不浪费篇幅伪伪的煽情,直插主题.(很长且多图,更多讲述的是实况FIFA间的你来我往,互相赶超的故事.本想全面展开描述细节, ...

  2. AIDL与service

    Service:Local service,一个进程中的多线程服务. AIDL:remote service,不同进程间通信. Service启动方法: startService():调用方destr ...

  3. Golang与MySQL

    1. 在golib下载go-sql-driver/mysql go get github.com/go-sql-driver/mysql 2. 代码引入 import ( "database ...

  4. 7.FPGA中的同步复位与异步复位

    1.异步复位 always @ ( posedge sclk or negedge s_rst_n ) if ( !s_rst_n ) d_out <= 1'b0; else d_out < ...

  5. P1119: [POI2009]SLO

    这题预处理稍微动动脑,其实还是个裸的置换群=-=,没什么压力. ; var n,i,j,minx,tem,now,tmin,len:longint; cursum,sum:int64; pos,num ...

  6. JavaScript显示输出

    记得c语言里的printf和java里的println吗,那么在JavaScript中怎么实现同样的功能呢 window.onload = function() { var para = docume ...

  7. java 图片处理

    /* * 图片处理类 */ package image; import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.j ...

  8. 基于.net mvc的校友录(三、实体模型实现)

    实体模型设计 由于是实际开发,而且是时间比较紧的,所以,在开发实现过程中,总有一些对原计划的改动: AlumniBookModel数据库实体模型 这是主数据实体类,EF会根据此实体生成数据库,它的每一 ...

  9. Notes of the scrum meeting(11/2)

    meeting time:13:00~13:30p.m.,November 2nd,2013 meeting place:3号公寓楼一层 attendees: 顾育豪                  ...

  10. 团队项目的NABC

    我们团队项目是做一个基于PC端的截屏软件,我觉得一个好的截屏软件需要具备磁性吸附的功能.当你需要对某个图像或者是其他的什么截屏的时候,精度比较高,不需要那些边框外的东西,磁性吸附就是在你选中的时候尽管 ...