$(this).hide(1000)//隐藏该元素

$(this).show(1000)//显示该元素

$(this).fadeIn(1000)//淡入已隐藏的元素

$(this).fadeOut(1000)//淡出已隐藏的元素

$(this).toggle(1000)//切换该元素的显示或隐藏状态

$(this).fadeToggle(1000)//淡出显示元素/淡入隐藏元素

$(this).slideUp(1000,callback)//下滑显示该模块

$(this).fadeTo("slow",0.5,showhello())//渐变为一半的浓度 ,然后执行showhello函数

$(选择到的元素).toggle(速度,返回函数名);

$(this).toggle(500,showhello())

var showhello=()=>{alert('hello')}

1.捕获元素

$(this).html   $(this).text

$("#btn2").click(function(){
alert("HTML: " + $(this).attr("mytap"));
});

<button id="btn2" mytap="这是一个随便写的内容">显示 HTML</button>

输出结果:HTML: 这是一个随便写的内容

prop()函数和attr()函数的区别

prop()函数的结果:

1.如果有相应的属性,返回指定属性值。

2.如果没有相应的属性,返回值是空字符串。

attr()函数的结果:

1.如果有相应的属性,返回指定属性值。

2.如果没有相应的属性,返回值是 undefined。

对于HTML元素本身就带有的固有属性,在处理时,使用prop方法。

对于HTML元素我们自己自定义的DOM属性,在处理时,使用 attr 方法。

具有 true 和 false 两个属性的属性,如 checked, selected 或者 disabled 使用prop()

添加元素的四类方法

  • append() - 在被选元素的结尾插入内容
  • prepend() - 在被选元素的开头插入内容
  • after() - 在被选元素之后插入内容
  • before() - 在被选元素之前插入内容

删除元素的方法

$(this).remove();//删除该元素及其子元素

$(this).empty();//删除该元素的子元素

例子:

$(this).remove(".mycalss") //删除 元素中 calss为myclass的元素

操作Class属性

$(this).addclass("mycalsss")

$(this).removeClass("myclass")

$(this).toggleClass("myclass")//该方法对被选元素进行添加/删除类的切换操作

获取该元素的css属性

$(this).css("background-color");//获取该元素的这个属性

$(this).css("background-color","#FF7F24");//修改该元素的属性值

最新文章

  1. ENode 2.6 架构与设计简介以及全新案例分享
  2. 1122MySQL性能优化之 Nested Loop Join和Block Nested-Loop Join(BNL)
  3. mmysql-最大链接数和最大并发数的区别
  4. myeclipse激活法,可以试一试
  5. Oracle中INSTR、SUBSTR和NVL的用法
  6. lodash的源码(1)
  7. Entity Framework 自动生成CodeFirst代码
  8. (C# Debug)A first chance exception of type &#39;System.ArgumentException&#39; occurred in System.Data.dll
  9. OpenCV Mat 类型定义和赋值
  10. js编译和执行顺序
  11. 被Oracle全局暂时表坑了
  12. 多线程并发编程之显示锁ReentrantLock和读写锁
  13. java 学习心得
  14. Linux select I/O 复用
  15. 新手上路---Java学习知识梳理
  16. #UnityTips# 2017.11.14
  17. 洛谷 [P1801] 黑匣子
  18. Hibernate中get()和load()方法区别
  19. oracle 的 exp 和imp命令
  20. laravel-admin安装时执行php arisan admin:install 命令时报SQLSTATE[42000]: Syntax error or acce ss violation: 1071 Specified key was too long; max key length is 1000 bytes

热门文章

  1. hiho一下 第四十九周 题目1 : 欧拉路&#183;一【无向图 欧拉路问题】
  2. ThinkPHP 小技巧
  3. UVA 1664 Conquer a New Region (并查集+贪心)
  4. matlab画圆
  5. html基础学习(注意点)
  6. java错误:The superclass &quot;javax.servlet.http.HttpServlet&quot; was not found on the Java Bu
  7. Cuckoo hash算法分析——其根本思想和bloom filter一致 增加hash函数来解决碰撞 节省了空间但代价是查找次数增加
  8. 【构建二叉树】02根据中序和后序序列构造二叉树【Construct Binary Tree from Inorder and Postorder Traversal】
  9. bzoj 2632 [ neerc 2011 ] Gcd guessing game —— 贪心
  10. Java精度计算与舍入