实例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>atter()和css()的使用</title> </head> <body> <img src="http://imgsrc.baidu.com/forum/w=580/sign=6ade238c064f78f0800b9afb49300a83/6cbb60d0f703918f31df8012543d269758eec47c.jpg" width="200px" alt="人物" title="图片" id="pic" data-nation="奥特曼"> </body> <script type="text/javascript" src="js/jquery-3.3.1.js"></script> <script type="text/javascript"> // attr()属性的获取与设置 var res = $('pic').attr('src','http://imgsrc.baidu.com/forum/w=580/sign=6ade238c064f78f0800b9afb49300a83/6cbb60d0f703918f31df8012543d269758eec47c.jpg') var res = $('pic').attr('style','border-radius:50%;box-shadow:2px 2px 4px #888') </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例