随笔 - 41,  文章 - 0,  评论 - 17,  阅读 - 16万
< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5

jQeury顶级对象 缩写$


1、$(document).ready(function(){
 
})
dom加载完成后触发
window.onload
 只能注册一个方法
 页面所有内容加载完成后触发(图片,css,js都加载)

 缩写
  $(function(){
  })
2、jQuery对象(包装集)  dom对象
 var div = document.getElementById("id") dom对象
 var div = $(".class") 包装集,对dom对象包装,返回的是很多个dom对象
3、jQeury选择器
 $("#id")
 $(".class")
 $("input")
 复合选择器 $("#id,.class,input")
 *
4 $(who).when(what)  $("#btn").click(function(){})
5、层次选择器
 $("div p") 包含选择器 div中所有的p 子元素 子子元素..
 $("div > p")  子后代选择器 div中直接子后代
6、常用的方法html()  text()  val()  attr()  css() removeAttr()
6.5 节点遍历
 next()  nextAll()
 prev()  prevAll()
 siblings()
 end()   andSelf()
7、简单选择器
 :first 选取第一个元素   $("div:first")
 :last 选取最后一个元素
 :not(选择器) 选取不满足“选择器”条件的元素$("div:not(#id)")
 :even、:odd,选取索引是奇数、偶数的元素
 :eq(索引序号)、:gt(索引序号)、:lt(索引序号)
8、设置样式
 css()
 attr("class","...")
 addClass("myclass")(不影响其他样式)
 removeClass("myclass")移除样式
 toggleClass("myclass")如果存在样式则去掉样式,如果没有样式则添加样式
 hasClass("myclass")判断是否存在样式
9、链式编程
 $(this).css("background-color", "red").siblings().css("background-color", "white");

---------------------------
10、属性过滤选择器
 $("div[id]")选取有id属性
 $("div[title=test]")选取title属性为test的元素
 $("div[title!=test]")选取title属性不为test的元素
 etc....查看帮助
11、表单选择器
 $(":input")匹配所有 input, textarea, select 和 button 元素
 $(":text")匹配所有 匹配所有的单行文本框
 $(":checkbox")匹配所有复选框
 etc.....查看帮助
12、动态创建Dom
 var link = $("<a href='http://www.baidu.com'>百度</a>");动态创建jquery对象,只是在内存中
 $("div:first").append(link);  把动态创建的jquery对象,加到第一个div中
 
 动态创建dom注意:
  var some = $("<div id='d1'>a<p></p>c</div>")
  当把动态创建的节点添加到窗体前,不能通过$("#d1")访问到它
  必须先把some追加到窗体
  $("div:first").append(some);
  才可以通过$("#d1") 中找到它

 append   把link元素追加到哪$("div:first").append(link); 
 appendTo  link.appendTo("div:first") 
  在结束标签之前添加元素
 prepend
 prependTo
  在开始标签之后添加元素
 after
 afterTo
  在结束标签外添加元素
 before
 beforeTo
  在开始标签前添加元素

13、删除节点
 remove()  删除当前节点
 empty() 清空当前节点之间的内容,节点保留

14、*替换节点
 $(“br”).replaceWith(“<hr/>”); 
15、*包裹节点
 wrap()将所有元素逐个用指定标签包裹


----------------------
16、绑定事件
 绑定事件 $("#id").bind("click",function(){})
 解除绑定 $("#id").unbind("click")
 让事件只执行一次 $("#id").one("click",function(){})
 合成事件hover  toggle
  hover(enterfn,leavefn)  当鼠标放上时执行enterfn,当鼠标离开时执行leavefn
  toggle(fn1,fn2) 当鼠标第一次点击时执行fn1,第二次点击执行fn2,以后依次执行
17、事件冒泡
 mouseover、mouseenter   mouseover会事件冒泡,mouseenter不会
 mouseout、mouseleave
 
 阻止事件冒泡
 $("#d1").click(function(e){ e.stopPropagation();})
18、*事件参数
 pageX、pageY
 target 获得触发事件的元素
 altKey、shiftKey、ctrlKey
 keyCode 键盘码、charCode  ascii码
19、动画
 show()、hide()
 toggle()  切换显示隐藏
 slideDown、slideUp、 fadeOut、fadeIn
 animate 复杂动画

 

 

 

posted @ 2011-12-01 23:20 幻想时空 阅读(1552) 评论(4) 推荐(2) 编辑
摘要: using System;using System.Web;using System.Drawing;using System.Web.SessionState;public class ValidateCode : IHttpHandler,IRequiresSessionState { public void ProcessRequest(HttpContext context) { //System.Threading.Thread.Sleep(5000); context.Response.ContentType = "image/jpeg"; ... 阅读全文
posted @ 2011-12-01 23:08 幻想时空 阅读(1670) 评论(0) 推荐(0) 编辑
摘要: //点击按钮添加评论 $("#btn").click(function (){ var content =$("#txtContent").val(); var id=$("#txtId").val(); var data="content="+content+"&id="+id +"&time="+new Date().getTime(); $.post("AddComment.ashx",dat... 阅读全文
posted @ 2011-12-01 22:53 幻想时空 阅读(2653) 评论(0) 推荐(0) 编辑
摘要: $.getJSON("Photolist.ashx",function (msg){ //每次加载之前清空 $("#content").html(""); //动态创建table var table=$("<table id='pList'></table>"); //添加表头 table.append($("<tr><th>序号</th><th>名字</th><th>照片</th> 阅读全文
posted @ 2011-12-01 22:47 幻想时空 阅读(474) 评论(0) 推荐(0) 编辑
摘要: <asp:ListView ID="ListView1" InsertItemPosition="LastItem" DataKeyNames="PId" runat="server" DataSourceID="ObjectDataSource1" > <ItemTemplate> <tr style=""> <td> <asp:Label ID="PIdLabel" runat="serv 阅读全文
posted @ 2011-12-01 22:30 幻想时空 阅读(3373) 评论(0) 推荐(0) 编辑
摘要: <asp:GridView ID="GridView1" runat="server" AllowPaging="True" DataSourceID="ObjectDataSource1" PageSize="2"> <Columns> <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" /> </Columns> </asp 阅读全文
posted @ 2011-12-01 22:25 幻想时空 阅读(160) 评论(0) 推荐(0) 编辑
摘要: <asp:DataList ID="DataList1" runat="server" CellPadding="4" DataSourceID="ObjectDataSource1" ForeColor="#333333" Width="243px" oncancelcommand="DataList1_CancelCommand" ondeletecommand="DataList1_DeleteCommand" onedit 阅读全文
posted @ 2011-12-01 22:22 幻想时空 阅读(7885) 评论(1) 推荐(0) 编辑
摘要: public void ProcessRequest (HttpContext context) { context.Response.ContentType = "image/jpeg"; //url传来的图片名 string img = context.Request.QueryString["img"]; if (!string .IsNullOrEmpty(img)) { //获取图片的物理路径 string path = context.Request.MapPath("... 阅读全文
posted @ 2011-12-01 22:15 幻想时空 阅读(451) 评论(0) 推荐(0) 编辑
摘要: cs://repeater的databound事件 protected void RptBig_ItemDataBound(object sender, RepeaterItemEventArgs e) { //此处必须做判断,不然下面获取数据会报没有实例化或者为空 if (e.Item.ItemType== ListItemType.Item||e.Item.ItemType== ListItemType.AlternatingItem) { Repeater rptSma... 阅读全文
posted @ 2011-12-01 20:38 幻想时空 阅读(1444) 评论(0) 推荐(0) 编辑
摘要: c#中结构和类,如何使用, 阅读全文
posted @ 2011-09-26 12:25 幻想时空 阅读(287) 评论(0) 推荐(0) 编辑
摘要: Aspose.Cells 首次使用,用到模版填充数据,合并单元格,换行 模版格式,图格式是最简单的格式,但实际效果不是这种,实际效果图如图2 图2 ,注意看红色部分,一对一是正常的,但是有一对多的订单,就得把前面的合并居中,后面对应多行显示 一般步骤: var templatePath = Serv 阅读全文
posted @ 2016-10-14 16:45 幻想时空 阅读(14820) 评论(2) 推荐(2) 编辑
摘要: function formatDatebox(value) { if (value == null || value == '') { return ''; } var dt = parseToDate(value); //关键代码,将那个长字符串的日期值转换成正常的JS日期格式 return dt.fo... 阅读全文
posted @ 2016-10-12 14:17 幻想时空 阅读(4527) 评论(1) 推荐(0) 编辑
摘要: 网上查找了很多例子,大多数是流,我只贴出一种简单的,至于复杂的流输出,懒得写,网上也很多例子 文件流是可以下载服务器文件,但是不能下载随便给的网络地址文件,所以蛋痛的查找了很多例子,最后发现 WebClient 的方法DownloadData,可以读取为byte[] 这就给了很大方便,几行代码搞定 阅读全文
posted @ 2016-08-18 17:18 幻想时空 阅读(266) 评论(0) 推荐(0) 编辑
摘要: RabbitMq window 搭建设置过程,网上有些说的不太明白,所以亲自操刀测试过程,参考了很多人的资料,多谢各位大神的宝贵资料第一步:装RabbitMq运行环境,类似一个虚拟机的东东 1.otp_win32_19.0.exe 下载地址:https://www.erlang.org/ 分32位和 阅读全文
posted @ 2016-08-12 17:37 幻想时空 阅读(747) 评论(0) 推荐(0) 编辑
摘要: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Text; using System.IO; using System.Drawing; using S 阅读全文
posted @ 2016-02-22 15:35 幻想时空 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 此文摘自csdn青山的博客地址:http://blog.csdn.net/a497785609/article/details/6437154本人随笔只为方便自己查阅,也为广大网友提供方便,不喜勿喷! #region 向Url发送post请求 /// /// 向Url发... 阅读全文
posted @ 2015-08-31 17:26 幻想时空 阅读(712) 评论(0) 推荐(0) 编辑
摘要: 1 //author:guan 2 //2015-05-25 3 //省市联动 4 //实用说明,页面引用如下js 5 // 6 // 7 //页面元素 8 // 9 //10 11 $(function () {12 //初始化下拉框值13 InitDropDown("Provi... 阅读全文
posted @ 2015-05-25 16:20 幻想时空 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 上次解释了几个易犯错的地方,当然对于大神们那都是小菜一碟了,今天来说说后台请求数据,分页,返回json数据废话不多说献上代码 private string QueryList(ArrayList arrayList) { //ArrayList ret = new Arra... 阅读全文
posted @ 2015-02-05 19:25 幻想时空 阅读(1598) 评论(0) 推荐(1) 编辑
摘要: 初次使用jquery.easyui这个东东,虽然简单,但还是很费力的去研究了一下使用,在使用过程中遇到的问题,下面代码会详细的注释到引用的文件jquery.min.js jquery.easyui.min.js样式:icon.css easyui.css页面初始化easy ui 插件 ... 阅读全文
posted @ 2015-02-03 19:31 幻想时空 阅读(12125) 评论(0) 推荐(3) 编辑
摘要: function startmarquee(lh, speed, delay) { var t; var oHeight = 373; /** div的高度 **/ var p = false; var o = document.getElementById("comList"); var pr... 阅读全文
posted @ 2014-12-03 15:45 幻想时空 阅读(4537) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示