zoukankan      html  css  js  c++  java
  • jQuery HTML

    1.获取和设置内容和属性

    text() - 设置或返回所选元素的文本内容
    html() - 设置或返回所选元素的内容(包括 HTML 标记)
    val() - 设置或返回表单字段的值
    attr() - 方法用于获取属性值

    $("#btn1").click(function(){ 
        $("#test1").text("Hello world!"); 
    }); 

    $("#btn1").click(function(){ 
        $("#test1").text(function(i,origText){ 
            return "aaa"; 
        }); 
    }); 

    $("button").click(function(){
      $("#runoob").attr("href","http://www.runoob.com/jquery");
    });

    $("button").click(function(){
      $("#runoob").attr("href", function(i,origValue){
        return "aaa"; 
      });
    });

    2.添加删除内容

    append() - 在被选元素的结尾插入内容
    prepend() - 在被选元素的开头插入内容
    after() - 在被选元素之后插入内容
    before() - 在被选元素之前插入内容

    remove() - 删除被选元素(及其子元素)
    empty() - 从被选元素中删除子元素

    3.css

    设置某个class 的css 然后赋给一些元素

    addClass() - 向被选元素添加一个或多个类
    removeClass() - 从被选元素删除一个或多个类
    toggleClass() - 对被选元素进行添加/删除类的切换操作

    css() - 设置或返回样式属性
    css("propertyname","value");
    css({"propertyname":"value","propertyname":"value",...});

    4.尺寸

    width() 方法设置或返回元素的宽度(不包括内边距、边框或外边距)。
    height() 方法设置或返回元素的高度(不包括内边距、边框或外边距)。
    innerWidth() 方法返回元素的宽度(包括内边距)。
    innerHeight() 方法返回元素的高度(包括内边距)。
    outerWidth() 方法返回元素的宽度(包括内边距和边框)。
    outerHeight() 方法返回元素的高度(包括内边距和边框)。

  • 相关阅读:
    新式类、经典类与多继承
    实现抽象类之方式二
    实现抽象类之方式一
    re模块
    28个高频Linux命令
    Git使用教程
    编程语言介绍
    编码
    进制
    操作系统简史
  • 原文地址:https://www.cnblogs.com/huoran1120/p/6008541.html
Copyright © 2011-2022 走看看