存档

文章标签 ‘jquery’

【笔记】 个人 jquery 常用函数

2009年3月31日 没有评论

iframe中刷新父页面

window.parent.location.reload()

调用父窗口中JS函数

self.parent.tb_remove();

选择符

jquery选择符

$(‘div.horizontal:eq(1)’) 从第一个开始算

CSS 选择符

$(‘div:nth-child(1)’) 第一个DIV

XPATH 选择符

$(‘input[@type="text"]‘).addClass(‘input’);
$(‘a[@href^="mailto:"]‘).addClass(‘mailto’);
$(‘a[@href$=".pdf"]‘).addClass(‘pdf’);
$(‘a[@href*="mysite.com"]‘).addClass(‘mysite’);

table tr 交替使用样式表

$(‘tr:odd’).addClass(‘oddclass’); 偶数 0开始的
$(‘tr:even’).addClass(‘evenclass’); 奇数
$(‘tr:not[th]:odd’).addClass(‘odd’);

关键词所在行高亮

$(‘td:contains(“关键词”)’).addClass(‘hight’);

$(‘td:contains(“关键词”)’).next().addClass(‘hight’);

取得同一级别td,除了包含23的所有td加样式表

$(‘td:contains(“23″)’).siblings().addClass(“redred”);
等价(td父级中找td编号大于0的加样式表)
$(‘td:contains(“23″)’).parent().find(‘td:gt(0)’).addClass(‘redred’);
等价
$(‘td:contains(“23″)’).parent().find(‘td’).not(‘:contains(“23″)’).addClass

(‘redred’);

包含23父级,在找到父级的第2个td,取消,再查找第3个td
$(‘td:contains(“23″)’).parent().find(‘td:eq(1)’).addClass(‘redred’).end().find

(‘td:eq(2)’).addClass(‘redred’);

或去ID所在的属性标签如 得到的是 body
$(“#table”).get(0).tagName;
$(“#table”).get(0) 等价 $(“#table”)[0]

迭代交替

.toggle() ;toggleClass.()<如果存在(不存在)就删除(添加)一个类>

.hover()

原创文章,转载请注明: 转载自DevNotes: Development with Notes

本文链接地址: 【笔记】 个人 jquery 常用函数

分类: JAVASCRIPT 标签: ,

jquery ajax轻松删除行,即时显示删除渐变

2009年3月27日 没有评论
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<script type="text/javascript">
	$(".deldata").click(function(){
		var id;
		id = $(this).attr('id');		
		if(confirm('确定删除吗?')){
			$.ajax({
			 type: "POST",
			 url: "/data/del",
			 data:   "id="+id,
			 success: function(msg){ $("#"+id).parent().parent().hide('slow');	 } 
			});	
		}	
	})
</script>
1
2
3
4
5
6
7
8
<table>
<tr>
<td><a class='deldata' id=1 >xxxxx</a></td>
</tr>
<tr>
<td><a class='deldata' id=2 >yyyyy</a></td>
</tr>
</table>

原创文章,转载请注明: 转载自DevNotes: Development with Notes

本文链接地址: jquery ajax轻松删除行,即时显示删除渐变

分类: AJAX, JAVASCRIPT 标签: , ,

jquery 轻松实现 双击编辑文本框

2009年3月26日 没有评论
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<script type="text/javascript">
$(document).ready(function(){
	$(".update").dblclick(function(){		
		id = $(this).attr('id');
		text = $(this).text();
			if(text){
			$(this).html("<input type='text' size=12 name="+id+" value="+text+">");
			$(".update > input").focus().blur(function(){				
				$.ajax({
				 type: "POST",
				 url: "/data/dbedit",
				 data:   "id="+id+"&no="+$("#"+id+" >input").val(),
				 success: function(msg){ $("#"+id).text(msg); } 
				}); 				
			})
		}
	})
 
})
</script>
1
2
3
4
5
<table>
</tr>
<td style="text-align:center;"   class="update" id="123" >文本内容</td>
</tr>
</table>

原创文章,转载请注明: 转载自DevNotes: Development with Notes

本文链接地址: jquery 轻松实现 双击编辑文本框

分类: JAVASCRIPT 标签: ,

jquery 1.3 中文手册

2009年3月16日 没有评论

和大家分享下 jquery 1.3 中文手册

jquery1.3_zh-090223

顺带提供下 learing jquery 的中文PDF资料(90.58MB)

http://www.namipan.com/d/Learning_jQuery_zh_CN.pdf/80341676e4c27c2302f1c5fc70e1129b5419162a2f47a905

原创文章,转载请注明: 转载自DevNotes: Development with Notes

本文链接地址: jquery 1.3 中文手册

分类: JAVASCRIPT 标签: