zoukankan      html  css  js  c++  java
  • 【JS教程24】jquery属性操作

    jquery属性操作

    1、html() 取出或设置html内容

    // 取出html内容
    
    var $htm = $('#div1').html();
    
    // 设置html内容
    
    $('#div1').html('<span>添加文字</span>');

    2、prop() 取出或设置某个属性的值

    // 取出图片的地址
    
    var $src = $('#img1').prop('src');
    
    // 设置图片的地址和alt属性
    
    $('#img1').prop({src: "test.jpg", alt: "Test Image" });

    练习:
    聊天效果

  • 相关阅读:
    2017.8.07
    2017.8.05
    2017.8.04
    2017.8.03
    2017.8.02
    2017.8.01
    2017.7.31
    2017.7.29
    2017.7.28
    简易日历
  • 原文地址:https://www.cnblogs.com/zeug/p/11399756.html
Copyright © 2011-2022 走看看