Jq.attr属性

一、attr属性
1返回文档中所有图像的src属性值
$("img").attr("src");
2.为所有图像设置src和alt属性
$("img").attr({ src: "test.jpg", alt: "Test Image" });
3、为所有图像设置src属性
$("img").attr("src","test.jpg");
4.把src属性的值设置为title属性的值
$("img").attr("title", function() { return this.src }); 

posted @ 2021-11-04 21:10  阿里郎丶  阅读(169)  评论(0编辑  收藏  举报