牛 JQuery视频笔记

QX3GLL
 
包装集  next() nextAll() nextAll("div");
  prev();prevAll()  end();andSlf();
eq(2);gt(1);lt(6);//里面的数字随便写
:first   :last   
:not(#ui)// :not(.myclass) //:not(#tl):not(.lj);
:odd() :even();

.index();//找到某一项的索引

$("td",$(this)).text("aaa");//当前点击这行里面的td
第一个元素是绝整个对定位:是在整个文档中找
第二个元素是相对定位:是在整个对象中找元素

行内样式:css
类样式:attr("class","样式的名字");相当于class="m",赋值,原来的样式没有了
addClass();removeClass();toggleClass();hasClass()


var $ta=$("<table id='td'></table>");
var $tr=$("<tr></tr>");
$td.append($tr);
var $td=$("<td><a href='#'>"+this.name+"</td>");
//给a标签注册事件
var $lind=$("a",$td);
$lind.click(function(){
 alert("123");
return false;
});
//方法二
$td.children("a").click(function(){
alert("通过对象的方法找到子元素");
return false;
});


倒计时的时候不用等到窗体加载完毕之后调用
var count=10;
var timeID =setInterval("setCount()",1000);//定时器执行的时候是在Window上找方法
function setCount(){
  if(count>0){
   count--;
    $("#id").val("请仔细阅读还剩下"+count+"秒");
}else{
  $("#id").val("同意").attr("disabled",false);
clearInterval(timeID );
}
}


$("mv li").mouseover(function(){
   $(this).css("background-color","red");
}).mouseout(function(){
   $(this).css("background-color","red");
});

remove();//方法可以移除事件  不会移除样式

项目中右下角的广告
<img id="i1" src="images/qqmsg.gif"/>
#il{
  position:fixed;
  right:0px;
  bottom:-150px;
}
<script type="text/javascript">
  $(function(){
   $("li").animate({"bottom":0},2000).anitmate({"opacity":0},5000);
})
</script>

//  放大镜效果
//判断cookie中是否有数值
var name=$.cookie("name");
if(name){
  alert(name);
}

///
$.cookie("name","value",{expires:7});


var name=$("#txtName").val();
var pwd=$("#txtPwd").val();
if(name=="admin"&&pwd="admin"){
//登录成功后把用户名保存到cookie中
var name=$.cookie("name")
if(name){
$("#txtName").val(name);
}

$("#login").click(function(){
  $.cookie("name",name,{expires,30});
   alert("登录成功");
}else{
alert("登录失败");
})

  

原文地址:https://www.cnblogs.com/alphafly/p/3485516.html