index() 当前标签的索引,data()给标签身上添加属性,each()循环遍历
1 2 3 4 5 6 7 8 9 10 |
|
选项卡 TAB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
表单注册验证
首先每个表单后面 带一个span , 用jquery 隐藏hide ,
然后在jquery获取input的value [ 这个可以用js对象 this.value] 来判断 如果成功 那么 next().show() ,以此类推
为了提交的时候强制验证,当from提交时候 给每个input执行blur,[ 判断的时候如果成功再给每个input 增加data({“num”:1}) ]
最后each tot+=这个属性 如果 tot不等于 总数 那么return false
$("input").not($("input[type='submit']"))
$("input[type!=submit]")
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
其他方法
1.data({"num":1}) 给jquery身上赋值
2.$('h1').each(function(i){
$(this).data({'num':i});
});
3.hover
$('img').hover(
function(){
this.src='b.png';
},
function(){
this.src='a.png';
}
);
eg:一个图片很大 鼠标滑过 移动位置
$('img').hover(
function(){
$(this).animate({
'margin-left':'-100px'
},500);
},
function(){
$(this).animate({
'margin-left':'0px'
},500);
}
);
$("img").hover(function () {
$(this).addClass('img');
},function () {
$(this).removeClass('img');
})
4.$('h1').length size和length获取jquery对象中dom对象的个数
5.$('#s1 option:selected').clone().appendTo('#s2');复制选择
6.全选 反选 和 全不选
$('#all').click(function(){
$(':checkbox').attr({'checked':true});
});
$('#notall').click(function(){
$(':checkbox').attr({'checked':false});
});
$('#unall').click(function(){
$(':checkbox').each(function(){
this.checked=!this.checked;
});
});
$('#ok').click(function(){
$(':checked').parent().parent().appendTo('.info');
});
7.
// $('h1:first').css({'color':'#00f'});
// $('h1:last').css({'color':'#00f'});
// $('h1:not(:first)').css({'color':'#00f'});
// $('h1:even').css({'color':'#00f'});
// $('h1:odd').css({'color':'#00f'});
// $('h1:eq(2)').css({'color':'#00f'});
// $('h1:gt(1)').css({'color':'#00f'});
// $('h1:lt(1)').css({'color':'#00f'});
8.$('h1[name!=user123]').css({'color':'#00f'});
9.$('h1').slice(2,3).css({'color':'#00f'});
从第几个到第几个