zoukankan      html  css  js  c++  java
  • jquery_1

    jqury

    1.alt VS title
    when your img does not show up,then you will see the alt on the page;
    and when mouseover the img,what you see is title;

    2.attr()
    get arrtibute value: you can use the function attr("attr_name") to access the attribute;
    also,you can set the attribute by the reload function attr("attr_name","attr_value");
    example:
    var txt = $("#myimg").attr("title"); //get the value of attribute title of myimg;
    $("p").attr("text",txt); //then set value of title to all the tag <p>'s text;

    3.addClass()
    we can add a defined class to the element of DOM by use to addClass() function;

    4.css()
    we can access the CSS of DOM elements;
    like:$("p").css("background-color","yellow");//to set the background of all <p> to yellow;
    $("p").css({color:red,background-color:yellow,font-size:16px});//set multiple css items;

    5.removeClass();
    remove the class of elements;

    6.html()
    get the html(contents) of elements(which means the innerHTML);

    7.eq()
    for DOM traversing,jquery have the function eq(index);
    like:seek for the third li of ul:$("li").eq(2); //careful,the selector is not ul but li;

    8.filter(selector)
    this function allow you to filter out the elements by selector;
    like:$("li").filter(".middle").addClass("selected");
    //get all the li,then filter out the class = middle,the set their class to seletes;

    9.find(selector);
    use this function ,we can find the child elements right in the range we get;
    like:$("p").find("span").addClass("selected");
    //get all the <p> elements,the find all its <span> children elements;

    10.width(value),height(value)
    set the width or height of selectors;
    like:$("div:first").width(100);//set the first div's width to 100;

    11.html() VS text()
    the function html() alaways mathch the innerHTML of the first selector
    while the function text() match the innerHTML of all the selectors;

    12. dl dt dd;
    dictionary list;dictionary theme; dictionary data;

    13.replaceWith(content)
    replace the innerHTML of selector;
    like:$("div").relaceWith("<h1>Hello World!</p>");

    14.remove()
    remove all the innerHTML of matched selectors;
    like:$("div").remove();

    15.after(),before();
    insert the html after or before the selector;
    like:$("div").after("<div class = "myDiv"><p>Hello World!</p></div>");

    16.append() VS after()
    append() means to append to the selector's innerHTML;
    while the after() is to insert the selector's HTML;

  • 相关阅读:
    show-meeting-subject-in-meeting-room-calendar
    前端模块化——彻底搞懂AMD、CMD、ESM和CommonJS
    微软到底有多恐怖?
    Office365云流程与开发授权错误
    JQuery实现省市联动 address-picker
    我的新作品 《平虏灭寇英杰传》
    ZT:C/C++ 字符串与数字相互转换
    C016:字符串倒置
    C015:十进制转8进制
    C014:不用算术分割显示逆序三位数
  • 原文地址:https://www.cnblogs.com/zengneng/p/5539809.html
Copyright © 2011-2022 走看看