热门关键字:
jquery > jquery教程 > jquery教程 > jQuery---属性操作

jQuery---属性操作

461
作者:管理员
发布时间:2020/2/13 19:08:23
评论数:0
转载请自觉注明原文:http://www.jq-school.com/Show.aspx?id=788
样式:在style里面写的,用css来操作
属性:在里面里面写的,用attr方法操作
 
    //设置单个属性 //attr(name, value) $("img").attr("alt", "图破了");
    $("img").attr("title", "错错错错");

 

      //设置多个属性 $("img").attr({
        alt: "图破了",
        title: "错错错",
        aa: "bb" })

 

console.log($("img").attr("alt"));

 

复制代码
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <img src="04.gif" alt="突破了" title="对对对"> <script src="jquery-1.12.4.js"></script> <script> $(function () { //设置多个属性  $("img").attr({
        alt: "图破了",
        title: "错错错",
        aa: "bb" })
      console.log($("img").attr("alt"));
    }); </script> </body> </html>
复制代码

 

jQuery---属性操作

 

 jQuery---属性操作

 

 





如果您觉得本文的内容对您的学习有所帮助:支付鼓励



关键字:jQuery
友荐云推荐