jQuery api学习笔记

jQuery事件

  • 各种事件类似点击事件
<html><head> <title>index.jsp</title><script type="text/javascript" src="js/jquery-3.2.1.js"></script><script>function click() {alert("you click me!");}$(function() {$("#btn1").click(function() {// 触发文本框的focus事件 并且会focus聚焦// $("input[name=txt1]").trigger("focus");// 不会执行浏览器默认动作$("input[name=txt1]").triggerHandler("focus");});$("input[name=txt1]").focus(function() {console.log(123);});// jQuery 事件绑定 on// 添加按钮$("#addBtn").click(function() {$("#div1").append("<input type='button' value='alert'/>");});// 绑定on 为div1中的button绑定了点击事件$("#div1").on("click", ":button", function() {alert("you click me!");});// 解除绑定事件$("#removeEvent").click(function() {$("#div1").off("click", ":button");});// 重新添加点击事件$("#addEvent").click(function() {$("#div1").on("click", ":button", click);});// hover 悬浮事件$("#div2").hover(function() {// in 悬浮到div//$(this).addClass("d1");$(this).toggleClass("d1");}, function() {// out 离开div//$(this).removeClass("d1");$(this).toggleClass("d1");});// 隐藏与显示操作$("#hideOrVisible").click(function() {// 可设置时间/fast/slow$("div").last().toggle("fast", function() {// 显示 或者 隐藏后要做的事情if ($("div").last().css("display") == "none") $("#hideOrVisible").val("显示");else$("#hideOrVisible").val("隐藏");});// $("div").last().toggle("showOrHide"); 点击隐藏或者点击});});</script><style>.d1 {background-color: pink;}</style></head><body><input type="text" name="txt1" /><input type="button" id="btn1" value="click"/><div id="div1"></div><input type="button" id="addBtn" value="add button" /><input type="button" id="removeEvent" value="remove disabled click" /><input type="button" id="addEvent" value="add enable click" /><br/><div id="div2" style="width: 300px;height: 100px;">999</div><br/><hr/><div style="width: 300px;height: 100px;" class="d1"></div><input type="button" id="hideOrVisible" value="隐藏" /></body></html>

jQuery 练习悬浮,点击变色

<html><head><title></title><script type="text/javascript" src="js/jquery-3.2.1.js"></script><script type="text/javascript">$(function() {// 鼠标悬浮事件$("tbody tr:gt(0)").hover(function() {				// 移入$(this).find("td").addClass("cg_color");}, function() {// 移出$(this).find("td").removeClass("cg_color");});$("tbody tr").click(function() {// $("tbody tr").find("td").removeClass("red");$(this).find("td").addClass("red");});// 鼠标移除 红色消失$("tbody tr").mouseout(function() {$(this).find("td").removeClass("red");});});</script><style>.cg_color {background-color: pink;}.red {background-color: red;}</style></head><body><table class="dataGrid"><tr class="dataGridHead"><td>书号</td><td>书名</td><td>价格</td><td>出版社</td><td>简介</td></tr><tr class="moveout"><td>1</td><td>精通struts</td><td>50</td><td>电子工业出版社</td><td>学习struts必备</td></tr><tr class="moveout"><td>2</td><td>精通hibernate</td><td>50</td><td>电子工业出版社</td><td>好书</td></tr><tr class="moveout"><td>3</td><td>spring宝典</td><td>50</td><td>电子工业出版社</td><td>一般般</td></tr><tr class="moveout"><td>4</td><td>精通tomcat</td><td>50</td><td>电子工业出版社</td><td>好书</td></tr><tr class="moveout"><td>5</td><td>精通struts2</td><td>50</td><td>电子工业出版社</td><td>一般般</td></tr></table>
</body>
</html>

表单失去焦点得到焦点对默认值判断

	<script type="text/javascript">//取表单默认值用dom对象的defaultValue获取,不能用value$(function() {// 链式操作$(":input").focus(function() {if ($(this).val() == this.defaultValue) {	// 文本框值和默认值相等$(this).val("");$(this).addClass("cg");}}).blur(function() {if ($(this).val() == "") {$(this).val(this.defaultValue);} else {$(this).removeClass("cg");}		});});</script>

load函数使用

	// 加载user信息 加载到action action帮我跳转/from1是表单$("#repairs_info").load("../../UserListAction.do?method=mutiplePageQuery", $("#form1").serialize(), function() {// load finish... do sth...});

更新…

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/420802.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

pow(x,n) leecode

https://oj.leetcode.com/problems/powx-n/ 提交地址 快速幂的使用&#xff0c;可以研究一下 1 public class Solution {2 public double pow(double x, int n) {3 4 if(n0) return 1.0;5 if(x1) return 1.0;6 if(x0)return 0;7 i…

1020 月饼 (25分)

输入样例&#xff1a; 3 20 18 15 10 75 72 45 输出样例&#xff1a; 94.50 解题心得&#xff1a; 本题因为要排序&#xff0c;优先考虑使用二维数组和sorted最常用的模式&#xff1b;python在建立二维数组时有一个坑&#xff0c;就是[[]] * n中出现浅拷贝问题&#xff0c;…

在Java web中使用json

json包下载 下载jar包当然是下大厂滴 推荐Alibaba的fastjson推荐Google的gjson 本文讲fastjson https://github.com/alibaba/fastjson.git json的常见格式 key - value 键值对 {"key":"value"}多个key - value对 {"key1":"value"…

方法重载

Overload&#xff1a; 1、一个类中方法名字一样&#xff0c;参数不一样的&#xff08;参数类型、参数个数&#xff09;&#xff0c;可构成重载&#xff1b; 2、构造方法中也可以使用方法重载&#xff1b; 转载于:https://www.cnblogs.com/link1220/p/3825252.html

1019 数字黑洞 (20分)

输入样例 1&#xff1a; 6767 输出样例 1&#xff1a; 7766 - 6677 1089 9810 - 0189 9621 9621 - 1269 8352 8532 - 2358 6174 输入样例 2&#xff1a; 2222 解体心得&#xff1a; 在初次写str2list时没有考虑到输入是‘123’这样的情形&#xff1b; # -*- coding: …

再看数据库——(2)视图

概念 *是从用户使用数据库的观点来说的。 *从一个或多个表&#xff08;视图&#xff09;中导出来的 *一个虚表&#xff0c;或者说查询表 为什么要用视图呢&#xff1f; 一是简单&#xff0c;看到的就是需要的。视图不仅可以简化用户对数据的理解&#xff0c;也可以简化他们的操…

spring bean的创建,生命周期

1. 初探spring 什么是spring Spirng 是分层的Java se/ee应用full-stack&#xff08;web层mvc dao层jdbc模板 业务事务管理&#xff09;轻量级开源框架&#xff0c;以IoC(inverse of control :反转和控制) 和 AOP&#xff08;Aspect Oriented Programming: 面向切面编程&#xf…

1025 反转链表 (25分)

输入样例&#xff1a; 00100 6 4 00000 4 99999 00100 1 12309 68237 6 -1 33218 3 00000 99999 5 68237 12309 2 33218 输出样例&#xff1a; 00000 4 33218 33218 3 12309 12309 2 00100 00100 1 99999 99999 5 68237 68237 6 -1 解题心得&#xff1a; 本题两个注意点&am…

网站如何启用SSL安全证书?IIS7启用新建Https:/

网站使用SSL&#xff0c;通过SSL证书申请&#xff0c;然后导入之后。我们需要对网站进行设置才能正常使用SSL证书&#xff0c;具体如何操作让网站启用SSL呢&#xff0c;本经验以一个网站添加SSL主机头的方式为例来&#xff0c;网站启用SSL服务器安全证书。(如果没有证书的&…

从0实现三层神经网络

本文目标 分享李沐老师关于深度学习的观点&#xff1a;1⃣️从实践的角度入手深度学习可能比单纯的研究算法更好&#xff1b;2⃣️如果想学习深度学习&#xff0c;要只用简单的数据结构&#xff0c;譬如numpy、NDArray&#xff0c;从0实现一个深度学习算法&#xff0c;这样才能…

js乱码解决

mmp最近在写项目&#xff0c;引入js文件&#xff0c;f12控制台老给我报红色的错误&#xff0c; 点开&#xff0c;是引入js文件中文乱码。。。反手myeclipse打开js文件&#xff0c;也正常啊&#xff0c;中文没乱码。。。 解决办法 打开js文件&#xff0c;设置为带bom的utf-8编码…

C# 去除所有的html标签

/// <summary> /// 去除所有的html标签 /// </summary> /// <param name"strhtml"></param> /// <returns></returns> public static string Removestriphtml(string strhtml) { string stroutput strhtml; Regex regex new R…

面向对象方法使用gluon

一、面向过程与面向对象的优缺点 面向过程使用mxnet&#xff0c;就是使用gluon封装好的对象&#xff0c;不加改动的表达机器学习的逻辑过程&#xff0c;其特点是方便、快捷&#xff0c;缺点是不够灵活&#xff08;虽然可以应对90%以上的问题了&#xff09;&#xff0c;面向对象…

Mapreduce执行过程分析(基于Hadoop2.4)——(一)

1 概述 该瞅瞅MapReduce的内部运行原理了&#xff0c;以前只知道个皮毛&#xff0c;再不搞搞&#xff0c;不然怎么死的都不晓得。下文会以2.4版本中的WordCount这个经典例子作为分析的切入点&#xff0c;一步步来看里面到底是个什么情况。 2 为什么要使用MapReduce Map/Reduce&…

spring配置数据源

spring配置数据源1. 什么是数据源连接池2. 手动创建数据源&#xff08;c3p0&#xff0c;druid&#xff09;2.1 导入数据库连接驱动&#xff0c;数据源pom坐标2.2 创建数据源2.3 配置jdbc.properties, 解耦拿到数据源3. spring配置数据源3.1 bean方式创建数据源13.2 bean方式创建…

基于mxnet的Regression问题Kaggle比赛代码框架

一、概述 书中3.16节扩展一下可以作为kaggle比赛的框架&#xff0c;这个赛题的名字是House Prices: Advanced Regression Techniques&#xff0c;是一个Regression问题。 二、Deeplearning的一般流程 结合李航《统计学习方法》中对机器学习流程的总结&#xff0c;分为data、…

centos8安装

一. 下载centos centos下载 下载镜像版 mini版本 二&#xff0c;安装centos8 虚拟机安装 可 打开虚拟机安装centos 选择下载的镜像 配置磁盘大小 配置资源 配置虚拟机内存&#xff0c;处理器个数等. 安装成功后&#xff0c;也可配置

alert,confirm和prompt

1.警告消息框alertalert 方法有一个参数&#xff0c;即希望对用户显示的文本字符串。该字符串不是 HTML 格式。该消息框提供了一个“确定”按钮让用户关闭该消息框&#xff0c;并且该消息框是模式对话框&#xff0c;也就是说&#xff0c;用户必须先关闭该消息框然后才能继续进行…