<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>attr就集合原生js的setattrbute和getattrbute两种属性</title> </head> <body> <p class="test">p标记</p> </body> <script type="text/javascript" src="jquery-1.11.1.min.js"></script> <script type="text/javascript"> $(function(){ alert('原来的class属性值'+$('p').attr('class')); $('p').attr('class','src'); alert('class属性值改为'+$('p').attr('class')); }) </script> </html>