jQuery基础复习(适用初学者)

该博客主要复习了前端相关知识,包含JavaScript的数据类型判断、函数定义与调用、数组操作、定时器使用等,还介绍了jQuery的选择器,如基本选择器、过滤选择器,以及鼠标、键盘、表单等事件的绑定与移除。

外部文件  .js
引用

嵌入在HTML标签
<input name=“btn” type=“button” value=“消息框” onclick(单击事件)=“javaScript:alert(‘欢迎你’)” />
undefined(未定义类型)
NaN(Not a Number)非数 number类型
typeof();判断数据类型
警告:alert("");
提示:prompt(“提示信息”,“输入框的默认信息”);
parseInt()  字符串转整数   从0开始找
parseFloat() 字符串转浮点数  从0开始找
自定义函数:function 函数名(参数){};
调用函数:事件名=“函数名()”;
window属性history,location  有关客户访问过的URL的信息,有关当前URL的信息
confirm(“文本内容”);  确定和取消
back() forward() go() 前一个url(后退) 后一个url(前进) 具体url
location reload()刷新
document referrer 载入本页面文档的地址
var 数组名称=new Array(size);
方法 join 分隔符  sort 排序 push 末尾添加,并返回长度  pop删除 循环 for(var 命名 in 数组名){doucment.write(数组名[命名]+
)}
setTimeout(“调用函数名称”,等待毫秒数);
setInterval(“调用函数名称”,周期性的毫秒数);
clearTimeout(setTimeout()返回的ID值);
clearInterval(setInterval()返回的ID值);
————————————————————————————————————————————————————————
getAttribute(“属性名”);获取属性的值
setAttribute(“属性名”,“属性值”);设置属性的值
innerHTML=“新内容”;
style.样式属性=“值”;
$(document).ready(function(){});
$(selector).action();
$(selector).addClass([样式名]);
KaTeX parse error: Expected 'EOF', got '#' at position 139: …根据给定的class匹配元素 #̲id 根据给定的class匹配…=value]   选取给定属性是以某个特定值结尾的元素
                    [attribute=value]   选取给定属性是包含某些值的元素
                    [selector1][selector2][selectorN]   选取满足多个条件的复合属性的元素
过滤选择器   :first 选取第一个元素
                    :last  选取最后一个元素
                    :not(selector)选取去除所有与给定选择器匹配的元素
                    :even  偶数
                    :odd   奇数
                    :eq(index)   选取索引等于index的所有元素  从0开始
                    :gt(index)   大于
                    :lt(index)    小于
基本过滤选择器    :header   选取所有标题元素  例如h1~h6
                           :focus     选取当前获取焦点的元素 
可见性过滤选择器   :visible   选取所有可见的元素
                              :hidden   选取所有隐藏的元素
鼠标事件:click()  单击鼠标
              mouseover()  移过时
              mouseout()   移出时
键盘事件:keydown()  按下按键时
              keyup()    释放按键时
              keypress()   产生可打印的字符时
表单事件:focus() 获得焦点
              blur() 失去焦点
绑定事件和移出事件:bind(type,[data],fn);
例如$(document).ready(function(){
$(“input[name=1]”).bind({
mouseover:function(){
$(“ul”).css();
},
mouseout:function(){
KaTeX parse error: Expected 'EOF', got '}' at position 15: ("ul").css(); }̲ }) }) 移出事件:unb…(selector)   $(element)  $(html)
var newNode=newNode=newNode=("

  • ");
    插入节点:内部插入  append(content)  向所选择的元素内部插入内容 (&quot;ul&quot;).append((&quot;ul&quot;).append(("ul").append(newNode);
                                    appendTo(content)    (((newNode).appendTo(“ul”);
                                    prepend(content)  向每个选择的元素内部前置内容 (&quot;ul&quot;).prepend((&quot;ul&quot;).prepend(("ul").prepend(newNode);
                                    prependTo(content)  (((newNode).prependTo(“ul”);
                     外部插入  after(content)  在每个匹配的元素之后插入内容  (&quot;ul&quot;).after((&quot;ul&quot;).after(("ul").after(newNode);
                                    insertAfter(content)  将所有匹配元素插入到指定元素的后面 (((newNode).insertAfter(“ul”);
                                    before(content) 向所选择的元素外部前面插入内容  (&quot;ul&quot;).before((&quot;ul&quot;).before(("ul").before(newNode);
                                    insertBefore(content) 将所匹配的元素插入到指定元素的前面(((newNode).insertBefore(“ul”);
    删除节点 $(selector).remove([expr]);全删
                  $(selector).empty();保结构删内容
    替换节点 (selector).replaceWith((selector).replaceWith((selector).replaceWith(newNode);
                  (((newNode).replaceAll(selector);
    复制节点 (selector).clone([includeEvents]);true/false true继承该事件属性操作:(selector).clone([includeEvents]); true/false  true继承该事件 属性操作:(selector).clone([includeEvents])true/false true(selector).attr([name])   (selector).attr([name1:value1],[name2:value2]...);删除属性:(selector).attr({[name1:value1],[name2:value2]...}); 删除属性:(selector).attr([name1:value1],[name2:value2]...);:(selector).removeAttr(name);
    节点遍历:遍历后代元素 $(selector).children([expr])
                     遍历同辈元素 方法 siblings()  $(“li”).siblings().css();  选取元素的所有同辈元素
                                                  next()  选取下一个同辈元素
                                                  nextAll()  选取被选元素的所有跟随的同辈元素
                                                  prev()紧邻匹配元素之前的元素
                                                  prevAll()  选取被选元素的所有之前的同辈元素
                     遍历前辈元素   $(selector).parent([selector])直接父类
                                            $(selector).parents([selector])所有祖先元素
                     遍历过滤方法   first()    $(“ul li”).first().css()
                                            last()
                                            eq()
    CSS-DOM  操作: css() 设置和返回匹配元素的样式属性  $("#box").css(“background-color”,“green”);
                                 height([value])  $("#box").heigh(180);
                                 width([value])   $("#box").width(180);
                                 p125
    控制元素显示和隐藏:显示  $(selector).css(“display”,“block”); 
                                     控制效果  $(selector).show([speed],[callback]); 可能值 (毫秒1000)、slow、normal、fast 默认值0。show函数执行完之后,要执行的函数
                                     隐藏   $(selector).hide([speed],[callback])
                                     淡入   $(selector).fadeIn([speed],[callback])  默认值400。 设置了speed才能设置callback
                                     淡出   $(selector).fadeOut([speed],[callback])
                                     下滑   $(selector).slideDown([speed],[callback])
                                     上滑   $(selector).slideUp([speed],[callback])

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值