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;

  • 相关阅读:
    [收藏]15分钟内快速构建数据访问层
    asp.net 水晶报表主从表关联问题
    C#基础——关于类
    C#和Sql的时间操作心得(一)
    DataGrid导出到Word/Excel文档
    [收藏]SQL Server 索引结构及其使用
    .NET环境下水晶报表使用总结
    读写文件之日志文件
    HashTable实现购物车,抛弃数据库实现方式
    触碰心灵34句
  • 原文地址:https://www.cnblogs.com/zengneng/p/5539809.html
Copyright © 2011-2022 走看看