jquery 包含的功能

1.HTML元素选取、操作
2.CSS操作
3.HTML事件函数
4.Javascript特效和动画

5.HTML DOM遍历和修改
6.AJAX
7. Untilities  工具类

基础
text()函数改变this中的文档内容
  1. $("li").click(function (){
  2. $(this).text("hello!boy!");
  3. });

before方法
  1. $("p").before('<h1>这是before的测试方法</h1>');
bind , unbind方法
bind 和unbind及onclikc和officlick方法都是调用on和off方法来实现的
  1. $("#test").bind(
  2. 'click',function (){
  3. alert("这是事件触发的文字")
  4. }
  5. );
  6. $("#test").unbind('click');

下面的这个不会用
event.stopPropagation();    阻止父级事件
event.stopImmendiatePropagation();  阻止所有的事件

  1. for(var i = 0; i<5;i++){
  2. $("<div style='color:red'>this is new word!</div>").appendTo(document.body); // 这个appendTO(document.body)很有用
  3. }

fadeToggle  隐藏函数
slideUp       也是隐藏函数
是两种不同的函数,其实Toggle的时间设置的适当的话,和fadeToggle差不多

animate动画方法
  1. $("button").click(function(){
  2. $("div").animate({
  3. left:'250px',
  4. opacity:'0.5',
  5. height:'150px',
  6. width:'150px'
  7. });
  8. });

jQuery 方法链接chaining

  1. $("#p1").css("color","red").slideUp(2000).slideDown(2000); // 让事件一次绑定多个方法

$("div").Remove()  不写就是删除所有元素
$("div").empty()     删除所有元素
$("div").addClass("style=color:red");   给DIV标签增加样式

outerHeight , outerWidth

  1. <p>Hello</p><p></p>
  2. <script>
  3. var p = $( "p:first" );
  4. $( "p:last" ).text(
  5. "outerHeight:" + p.outerHeight() +
  6. " , outerHeight( true ):" + p.outerHeight( true ) );
  7. </script>
  1. 输出 outerHeight:33 , outerHeight( true ):53


Jquery 的遍历和过滤
同级遍历
向下遍历 find  在标签中找,find中必须写元素
  1. <p><span>Hello</span>, how are you?</p>
  2. <p>Me? I'm <span>good</span>.</p>
  1. $( "p" ).find( "span" ).css( "color", "red" );
向上遍历 
parent 在标签的外层查找一个包含的母元素作为选择器
parents 在外层查找匹配的标签,没有的话就选择所有的外层标签
  1. $( "li.item-a" ).parent().css( "background-color", "green" );
  2. $( "li.item-a" ).parents("li").css( "background-color", "green" );

 向下遍历next    同级遍历 siblings
  1. $("h2").siblings().css({borer:"3px solid #ff0022}); //选择除了自己以外的其他同级元素
  2. $("h2").next().css({border:"3px solid #ff0022});
  3. $("h2").nextAll().css({border:"3px solid #ff0022});
  4. $("h2").nextUntil("h4").css({border:"3px solid #ff0022}); // 这个只能往下找

  向下遍历  first  last  eq  filter
  1. $("li").first().css("background-color","red");
  2. $("li").last().css("background-color","red");
  3. $("li").eq(1).css("background-color","red"); // 选择第二个li元素
  4. $("li").filter(".item-1").css("background-color","red"); // 第二次过滤,选择class = item-1的元素

jquery扩展
  1. $.noConflict(); // 这个声明了之后就不能再使用$符号了,必须自定义关键字来写语句,不一定非要使用jQuery关键字
  2. jQuery("li").click(function (){
  3. jQuery(this).text("hello!boy!");
  4. });
jQuery UI
1.交互,一些与鼠标相关的内容
Draggable,Droppable,Resizable,Selectable,Sortable
2.小部件,一些界面的扩展
AutoComplete,ColorPicker,Dialog,Slider,Tabs,ProgressBar,Spinner
3.效果,提供丰富的动画效果
Add Class , Color Animation , Toggle

unload 和 beforeunload 

unload 和 beforeunload 都没法区分刷新和关闭,只要当前页面unload了就会触发(关闭,刷新,点击链接,输入地址等等)

unload 可以做些清理工作,但是不能用preventDefault来阻止页面关闭。(jquery unload )

alert实际执行了,只是大部分浏览器会阻止正在关闭的窗口弹对话框。如果你用chrome,可以打开Developer Tool并点击右下角的齿轮设置,选择 Preserve log upon navigation,可以查看到unload里的console.log。因为unload一返回,页面就关闭,如果有ajax请求什么的,都一定要同步调用(async:true),不然页面unload完资源就全部注销了。

beforeunload 如果返回值不是null或者undefined,浏览器会负责跳出个confirm对话框,返回值可以会做为提示的一部份也可能压根就不用。

唯一能阻止页面关闭的就是beforeunload返回truthy value,并且用户点击了Cancel/No

Chrome不支持本地Ajax请求,当我在.html文件中访问.json文件时就会出现这个问题,就是说这html文件。所以调试的时候需要有web服务器。

所以下面代码中的url是无法访问的

  1. $(document).ready(function(){
  2. $("#b01").click(function(){
  3. htmlobj=$.ajax({url:"e:/test1.txt",async:false});
  4. $("#myDiv").html(htmlobj.responseText);
  5. });
  6. });


DOM 用途说明 Jquery
document.createElement(TagName) 创建元素 $("TagName")
parentElement.appendChild(Element)  附加子节点 $parentElement.Append() 
$Element.AppendTo(parentElement) 
parentElement.insertBefore(Element, siblingElement)  parentElement.insertBefore(siblingElement, Element) 插入兄弟节点 $(siblingElement).before(Element)
$(siblingElement).after(Element)
document.GetElementById(ElementId) 通过ID属性获取元素 $("#ElementId")
document.GetElementsByTagName(ElementsTagName) 通过标签名称获取元素 $("TagName")
document.GetElementsByName(ElementsName) 通过Name属性获取元素 $("Elements[name=ElementsName]")
Element.parentNode.removeChild(Element) 移除元素 $Element.remove() 
Element.innerText 获取或设置元素的innerText $Element.Text()
Element.innerHTML 获取或设置元素的innerHTML $Element.HTML()
Element.className
Element.style
获取或设置元素的样式表 $Element.addClass(className)
$Element.toggleClass(className) $Element.removeClass(className)
Element.cssText 获取或设置元素的style $Element.css()
Element.getAttribute(attributeName) 获取元素的value $Element.attr(attributeName)
Element.setAttribute(attributeName, attributeValue) 设置元素的value $Element.attr(attributeName, attributeValue)
Element.parentNode 获取元素的父节点 $Element.parent()
Element.childNodes 获取元素的子节点 $Element.children()
Element.previousSibling 获取元素的前一个兄弟元素 $Element.prev()
Element.nextSibling 获取元素的后一个兄弟元素 $Element.next()
window.onload() = function() {}; 绑定窗体加载事件 $(document).ready(function() {});
$(function() {});
Element.onclick = function() {}; 绑定元素的单击事件 $Element.click(function() {});


简单选择器
$("#ElementId") ID选择器
$("TagName") 标签选择器
$(".ClassName") 类名选择器
$("*") 通配符选择器
$("Selector1, Selector2,…, SelectorN") 组合选择器
层次选择器
$("Selector1 Selector2") 后代选择器
$("Selector1 > Selector2") 子代选择器
$("Selector1 + Selector2") 相邻兄弟选择器
$("Selector1 ~ Selector2") 兄弟选择器
子元素选择器
$(":nth-child(index/even/odd/equation)")
$(":first-child")
$(":last-child")
$(":only-child")
滤镜选择器
$(":first")
$(":last")
$(":even")
$(":odd")
奇偶数选择器
$(":eq(index)")
$(":gt(index)")
$(":lt(index)")
不等式选择器
$(":visible")
$(":hidden")
可见性选择器
$(":header") 标题选择器
$(":animated") 动画选择器
$(":not(filter)") 反选选择器
表单选择器
$(":button") 按钮
$(":checkbox") 复选框
$(":file") 文件域
$(":hidden") 隐藏元素
$(":image") 图像域
$(":input") 输入控件
$(":password") 密码框
$(":radio") 单选按钮
$(":reset") 重置按钮
$(":submit") 提交按钮
$(":text") 单行文本框
$(":enabled") 可用元素
$(":disabled") 不可用元素
$(":checked") 适用于checkbox、radio 选中元素
$(":selected") 适用于option

Jquery-基础知识点的更多相关文章

  1. jQuery基础知识点(下)

    在实际开发中,jQuery的实践性非常强大.上一篇本人已经整理出了一部分基础知识点,该文即是对以上的补充和扩展. 1.表单值的操作 //获取文本框的值 //txt.value var val = $( ...

  2. jQuery基础知识点(DOM操作)

    1.样式属性操作     1)设置样式属性操作         ①设置单个样式: // 第一个参数表示:样式属性名称 // 第二个参数表示:样式属性值 $(selector).css(“color”, ...

  3. Jquery基础知识点

    1.选择器:查找和过滤 查找:向下查找用find(),  向上查找用parent(),  同级查找用next(),  prev() 过滤:和函数式编程的map.filter类似,jQuery对象也有类 ...

  4. jQuery基础知识点(上)

    jQuery是一个优秀的.轻量级的js库 ,它兼容CSS3,还兼容各种浏览器(IE 6.0+, FF1.5+, Safari 2.0+, Opera 9.0+),而jQuery2.0及后续版本将不再支 ...

  5. jquery基础知识点总结

    Jquery是一个优秀的js库,它简化了js的复杂操作,不需要关心浏览器的兼容问题,提供了大量实用方法. Jquery的写法 方法函数化 链式操作 取值赋值合体] $(“p”).html();   取 ...

  6. Jquery基础知识点梳理

    1.第一个jq程序 a.jq对象和dom对象的方法不能混用 b.dom对象转换成jq对象$(dom),jq对象转换成dom对象jq[0],转换之后方法就可以使用了 2.jq选择器 基本选择器 $('b ...

  7. .NET基础知识点

    .NET基础知识点   l  .Net平台  .Net FrameWork框架   l  .Net FrameWork框架提供了一个稳定的运行环境,:来保障我们.Net平台正常的运转   l  两种交 ...

  8. JavaScript 开发者经常忽略或误用的七个基础知识点(转)

    JavaScript 本身可以算是一门简单的语言,但我们也不断用智慧和灵活的模式来改进它.昨天我们将这些模式应用到了 JavaScript 框架中,今天这些框架又驱动了我们的 Web 应用程序.很多新 ...

  9. JavaScript 开发者经常忽略或误用的七个基础知识点

    JavaScript 本身可以算是一门简单的语言,但我们也不断用智慧和灵活的模式来改进它.昨天我们将这些模式应用到了 JavaScript 框架中,今天这些框架又驱动了我们的 Web 应用程序.很多新 ...

  10. JavaScript开发者常忽略或误用的七个基础知识点

    JavaScript 本身可以算是一门简单的语言,但我们也不断用智慧和灵活的模式来改进它.昨天我们将这些模式应用到了 JavaScript 框架中,今天这些框架又驱动了我们的 Web 应用程序.很多新 ...

随机推荐

  1. SpringBoot+Maven聚合多项目打包成jar

    已我最近自己在玩的一个DEMO为例 taosir为pom.xml,其他子项目均为其modules,且为jar项目 eureka为注册中心.workflow为提供者.entrance为调用方 entra ...

  2. webpack的热更新

    webpack的热更新是如何做到的?说明其原理? webpack的热更新又称热替换(Hot Module Replacement),缩写为HMR. 这个机制可以做到不用刷新浏览器而将新变更的模块替换掉 ...

  3. IE9以下版本兼容h5标签

    随着html5(后面用h5代表)标签越来越广泛的使用,IE9以下(IE6-IE8)不识别h5标签的问题让人很是烦恼. 在火狐和chrome之类的浏览器中,遇到不认识的标签,只要给个display:bl ...

  4. ASP.NET-后台cookie与前台JQUERY解析cookie

    在controller中给cookie赋值 HttpCookie cookie =newHttpCookie("pageInfo"); cookie["page_inde ...

  5. android:px,dp(dip),sp的差别

    1.px:表示屏幕的实际像素,比如320*480的屏幕在横向有320个像素,在纵向有480个像素,假设指定的某个空间的单位为px.那么在不同分辨率下的手机上.显示的都是指定的大小.一般不推荐使用px. ...

  6. HDU Train Problem I (STL_栈)

    Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot o ...

  7. 第十七章_Web注解

    1.HandlesTypes 这个注解类型用来声明ServletContainerInitializer能够处理哪些类型的类.它有一个属性.一个值.用来声明类的类型.比如,以下的ServletCont ...

  8. 关闭 sftp

    vi /etc/ssh/sshd_config 注释掉这行Subsystem  sftp    /usr/libexec/openssh/sftp-server /etc/rc.d/init.d/ss ...

  9. Redis和Memcache和MongoDB简介及区别分析(整理)

    Redis和Memcache 一.Redis简介 Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API.从2010年 ...

  10. [Codeforces 1051F] The Shortest Statement 解题报告(树+最短路)

    题目链接: https://codeforces.com/contest/1051/problem/F 题目大意: 给出一张$n$个点,$m$条边的带权无向图,多次询问,每次给出$u,v$,要求输出$ ...