jQuery DOM操作
jQuery DOM操作 标签属性操作 attr() //getAttrbute() setAttrbute() 路径的相对地址 removeAttr() //removeAttibute() <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <img src="./xiaohua.jpg" alt="" > <script src="./libs/jquery-3.3.1.js"></script> <script> $(function () { //attr //获取值 console.log($('img').attr('src')); //./xiaohua.jpg //设置值 $('img').attr('alt','美女'); //./xiaohua.jpg //设置多个标签属性值 $('img').attr({ 'aaa':'美女', 'bbbb':'个哈哈哈' }); //移除 removeAttr() setTimeout(()=>{ //移除单个属性 // $('img').removeAttr('alt'); //移除多个属性 $('img').removeAttr('alt aaa bbbb'); },3000