分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

jquery

发布时间:2023-09-06 02:19责任编辑:彭小芳关键词:暂无标签

jQuery 对象就是通过jQuery包装DOM对象后产生的对象。jQuery 对象是 jQuery 独有的如果一个对象是 jQuery 对象那么它就可以使用 jQuery 里的方法: $(“#test”).html();

jquery的基础语法:$(selector).action()

选择器

 基本选择器    

$("*")  $("#id")   $(".class")  $("element")  $(".class,p,div")

 层级选择器   

$(".outer div")  $(".outer>div")   $(".outer+div")  $(".outer~div")

基本筛选器    

$("li:first")  $("li:eq(2)")  $("li:even") $("li:gt(1)")

 属性选择器 

$(‘[id="div1"]‘)   $(‘["alex="sb"][id]‘)

表单选择器    

$("[type=‘text‘]")----->$(":text")         注意只适用于input标签  : $("input:checked")

 筛选器

过滤筛选器 

$("li").eq(2)  $("li").first()  $("ul li").hasclass("test")

 查找筛选器

$("div").children(".test") ?????   $("div").find(".test") ????????????????????????????????
$(".test").next() ???       ??$(".test").nextAll() ????   $(".test").nextUntil()
??????????????????????????
$("div").prev() ?       ??????$("div").prevAll() ?   ?????$("div").prevUntil() ??
???????????????????????
$(".test").parent() ?       $(".test").parents() ?   ??$(".test").parentUntil()
$("div").siblings()

 操作元素(属性,css,文档处理)

属性操作

--------------------------属性$("").attr();$("").removeAttr();$("").prop();$("").removeProp();--------------------------CSS类$("").addClass(class|fn)$("").removeClass([class|fn])--------------------------HTML代码/文本/值$("").html([val|fn])$("").text([val|fn])$("").val([val|fn|arr])---------------------------$("").css("color","red")

文档处理

//创建一个标签对象 ???$("<p>")//内部插入 ???$("").append(content|fn) ?????----->$("p").append("<b>Hello</b>"); ???$("").appendTo(content) ??????----->$("p").appendTo("div"); ???$("").prepend(content|fn) ????----->$("p").prepend("<b>Hello</b>"); ???$("").prependTo(content) ?????----->$("p").prependTo("#foo");//外部插入 ???$("").after(content|fn) ??????----->$("p").after("<b>Hello</b>"); ???$("").before(content|fn) ?????----->$("p").before("<b>Hello</b>"); ???$("").insertAfter(content) ???----->$("p").insertAfter("#foo"); ???$("").insertBefore(content) ??----->$("p").insertBefore("#foo");//替换 ???$("").replaceWith(content|fn) ----->$("p").replaceWith("<b>Paragraph. </b>");//删除 ???$("").empty() ???$("").remove([expr])//复制 ???$("").clone([Even[,deepEven]])

css操作

CSS ???????$("").css(name|pro|[,val|fn]) ???位置 ???????$("").offset([coordinates]) ???????$("").position() ???????$("").scrollTop([val]) ???????$("").scrollLeft([val]) ???尺寸 ???????$("").height([val|fn]) ???????$("").width([val|fn]) ???????$("").innerHeight() ???????$("").innerWidth() ???????$("").outerHeight([soptions]) ???????$("").outerWidth([options])

事件

jquery

原文地址:https://www.cnblogs.com/roygood/p/9824362.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved