前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >jquery 基础

jquery 基础

作者头像
用户5760343
发布2019-08-26 18:09:22
4650
发布2019-08-26 18:09:22
举报
文章被收录于专栏:sktjsktj

1 hide 按钮隐藏

id

. class p.class p#xxx

("[href]") href= href!=
("[href]") href= href!=

("[href$='.jpg']") 选取所有 href 值以 ".jpg" 结尾的元素。

2 css $("p").css("background-color","red");

hide("slow")

show

("p").hide(1000);
("p").hide(1000);

("p").toggle();

(selector).fadeIn(speed,callback);
(selector).fadeIn(speed,callback);

(selector).fadeOut(speed,callback);

(selector).fadeToggle(speed,callback);
(selector).fadeToggle(speed,callback);

(selector).fadeTo(speed,opacity,callback);

3\

(selector).slideDown(speed,callback);
(selector).slideDown(speed,callback);

(selector).slideUp(speed,callback); $(selector).slideToggle(speed,callback);

4 animate

(selector).animate({params},speed,callback);
(selector).animate({params},speed,callback);

("button").click(function(){

("div").animate({left:'250px'}); });
("div").animate({left:'250px'}); });

("button").click(function(){

("div").animate({ left:'250px', opacity:'0.5', height:'150px', width:'150px' }); });
("div").animate({ left:'250px', opacity:'0.5', height:'150px', width:'150px' }); });

("button").click(function(){ $("div").animate({ left:'250px', height:'+=150px', width:'+=150px' }); });

callback $("p").hide(1000,function(){ alert("The paragraph is now hidden"); });

链式写法 $("#p1").css("color","red").slideUp(2000).slideDown(2000);

text() html() val() attr("href")

更改属性:

("button").click(function(){
("button").click(function(){

("#w3s").attr({ "href" : "http://www.w3school.com.cn/jquery", "title" : "W3School jQuery Tutorial" }); });

("p").append("Some appended text.");
("p").append("Some appended text.");

("p").prepend("Some prepended text.");

("img").after("Some text after");
("img").after("Some text after");

("img").before("Some text before");

("#div1").remove();
("#div1").remove();

("#div1").empty(); $("p").remove(".italic");

("button").click(function(){
("button").click(function(){

("h1,h2,p").removeClass("blue"); });

("button").click(function(){
("button").click(function(){

("h1,h2,p").toggleClass("blue"); });

("button").click(function(){
("button").click(function(){

("h1,h2,p").addClass("blue"); $("div").addClass("important"); });

("p").css("background-color");
("p").css("background-color");

("p").css("background-color","yellow");

("p").css({"background-color":"yellow","font-size":"200%"});
("p").css({"background-color":"yellow","font-size":"200%"});

("button").click(function(){ var txt=""; txt+="Width: " +

("#div1").width() + "</br>"; txt+="Height: " +
("#div1").width() + "</br>"; txt+="Height: " +

("#div1").height(); $("#div1").html(txt); });

("button").click(function(){ var txt=""; txt+="Inner width: " +
("button").click(function(){ var txt=""; txt+="Inner width: " +

("#div1").innerWidth() + "</br>"; txt+="Inner height: " +

("#div1").innerHeight();
("#div1").innerHeight();

("#div1").html(txt); });

("button").click(function(){ var txt=""; txt+="Outer width: " +
("button").click(function(){ var txt=""; txt+="Outer width: " +

("#div1").outerWidth() + "</br>"; txt+="Outer height: " +

("#div1").outerHeight();
("#div1").outerHeight();

("#div1").html(txt); });

$("span").parent();

("span").parents();
("span").parents();

("span").parents("ul"); $("span").parentsUntil("div");

$("div").children();

("div").children("p.1");
("div").children("p.1");

("div").find("span"); $("div").find("*");

("h2").siblings();
("h2").siblings();

("h2").next();

("h2").nextAll();
("h2").nextAll();

("h2").nextUntil("h6"); jQuery prev(), prevAll() & prevUntil() 方法

("div p").first();
("div p").first();

("div p").last();

("p").eq(1);
("p").eq(1);

("p").not(".intro");

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019.08.25 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • id
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档