zoukankan      html  css  js  c++  java
  • jquery 属性

    attr 设置或返回被选元素的属性值。

    $("img").attr("src");     返回文档中所有图像的src属性值。
    $("img").attr({ src: "test.jpg", alt: "Test Image" }); 为所有图像设置src和alt属性。
    $("img").attr("src","test.jpg");

    $("img").attr("title", function() { return this.src });

    removeAttr() 移除属性
    $("img").removeAttr("src"); 


    $("input[type='checkbox']").prop("checked");
    $("input[type='checkbox']").prop("checked", true);

    var $para = $("p");
    $para.prop("luggageCode", 1234);
    $para.append("The secret luggage code is: ", String($para.prop("luggageCode")), ". ");
    $para.removeProp("luggageCode");
    $para.append("Now the secret luggage code is: ", String($para.prop("luggageCode")), ". ");

    addclass  添加类

    $("p").addClass("selected");
    $("p").addClass("selected1 selected2");
    为每个匹配的元素添加指定的类名。一个或多个要添加到元素中的CSS类名,请用空格分开

    removeClass   移除类

    $("p").removeClass("selected");    一个或多个要删除的CSS类名,请用空格分开
    $("p").removeClass();              删除匹配元素的所有类

    toggleClass 交替显示类,如果存在(不存在)就删除(添加)一个类。

    $("p").toggleClass("selected");


    html() text() val()


  • 相关阅读:
    样式的使用
    样式的使用
    jqurey基础一
    jQuery三天复习.md
    webstorm快捷键大全
    计算机的进制与编码
    2016-4-29HTML标记的使用
    HTML的基本概况
    Apache Maven 入门篇 ( 上 )
    ehcache.xml 分布试缓存
  • 原文地址:https://www.cnblogs.com/MdpHappyForEver/p/5343548.html
Copyright © 2011-2022 走看看