zoukankan      html  css  js  c++  java
  • jQuery-HTML

    知识点一:jQuery对HTML的设置与捕获

    1、text():设置或返回所选元素的文本内容

    返回:$("#btn1").click(function(){

    alert("Text:"+$("#test").text());

    });

    设置:$("#btn1").click(function(){

    $("#test1").text("Helloworld!");

    });。

    2、html():设置或返回所选元素的内容(包括HTML标记、注释、属性、文本)

    返回:$("#btn2").click(function(){

    alert("HTML:"+$("#test").html());

    });

    设置:$("#btn2").click(function(){

    $("#test2").html("<b>Helloworld!</b>");

    });

    3、val():设置或返回表单字段的值

    返回:$("#btn1").click(function(){

    alert("值为:"+$("#test").val());

    });

    设置:$("#btn3").click(function(){

    $("#test3").val("RUNOOB");

    });

    4、attr()、prop():用于获取和返回属性值。

    1、prop()具有true和false两个属性的属性,如checked,selected或者disabled使用prop(),其他的使用attr()

    2、prop()可以设置返回被选元素的本身属性,但自定义属性不行

    3、attr()不仅可以返回(设置)元素的原生属性,还可以返回(设置)自定义属性

    4、$("button").click(function(){

    alert($("#runoob").attr("href"));

    });

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

    $("#runoob").attr("href","http://www.runoob.com/jquery");

    });

    知识点二、jQuery对HTML的页面尺寸操作

    1、width()方法设置或返回元素的宽度(不包括内边距、边框或外边距,不用加px)==width

    2、height()方法设置或返回元素的高度(不包括内边距、边框或外边距, 不用加px)==height

    3、innerWidth()方法返回元素的宽度(包括内边距)==clientWidth

    4、innerHeight()方法返回元素的高度(包括内边距)==clientHeight

    5、outerWidth()方法返回元素的宽度(包括内边距和边框)==offsetWidth

    6、outerHeight()方法返回元素的高度(包括内边距和边框)==offsetHeight

    7、scrollTop()方法设置或者返回滚动条被卷去的元素的高度

    8、scrollLeft()方法设置或者返回滚动条被卷去的元素的宽度

  • 相关阅读:
    在CentOS 7.6上安装VNC Server
    CentOS7.6 安装Docker
    CentOS 7.6 安装 Weblogic 12
    CentOS 7.6 安装Oracle 12c
    Spring MVC 使用介绍(五)—— 注解式控制器(一):基本介绍
    Spring MVC 使用介绍(四)—— 拦截器
    Spring MVC 使用介绍(三)—— Controller接口控制器
    Spring MVC 使用介绍(二)—— DispatcherServlet
    Spring MVC 使用介绍(一)—— 概述
    Spring 使用介绍(十三)—— Bean的生命周期
  • 原文地址:https://www.cnblogs.com/wangxue13/p/13474679.html
Copyright © 2011-2022 走看看