1<! DOCTYPE html>2"en">34<meta charset="UTF-8">5<title>wrap</title>6<script type="Text/javascript"Src=".. /jquery/jquery-1.11.3.min.js"></script>7<style type="Text/css">8. lianjie{display:inline-block;border:1px Solid Red}9 . border{border:1px Solid Red}Ten . border1{outline:4px dotted Green} One</style> A -<body> -<a href="http://www.baidu.com" class="Baidu"> Baidu </a> the<a href="http://www.souhu.com" class="Souhu"> Baidu </a> -<a href="http://www.xinlang.com" class="XINLNG"> Baidu </a> -"1.jpg"alt="This is a picture ."/> - +<script type="Text/javascript"> - $ (document). Ready (function () { +$("img"). AddClass (" Picture");//Add Class attribute A$("img"). Removeclass (" Picture"). AddClass ("T_pic");//Delete and add Class attribute atConsole.log ($ ("img"). Hasclass ("T_pic"));//Hasclass Detect if a class attribute exists - -$("a:odd"). AddClass ("Lianjie");//odd odd even even - -$("a"). addclass (function (index,eclass) {//dynamically adding the Class Property index is an index Elcass processing the class property owned by the current element - if(index%2==0){ in return "even"; -}Else{ to return "Odd"; + } - }); the *$("a"). Filter (": Odd"). AddClass ("Oddclass"). End ()//filter () filters the matching list of elements to the previous state until the last destructive operation is returned by the result set end () of the expression match $. Filter (": Even"). AddClass ("Evenclass");Panax Notoginseng -$("<button>toggle</button>"). AppendTo ("Body"). Click (dotoggle); the + function Dotoggle (e) { A //$ ("img"). Toggleclass ("border");//Toggleclass Switch Class the //$ ("img"). Toggleclass ("Border Border1");//Toggleclass Switching multiple class + //$ ("img"). Toggleclass ();//toggleclass () switch all class without adding parameters - //$ ("img"). Toggleclass ("border", false);//Toggleclass () the second parameter is false to delete only $ //$ ("img"). Toggleclass ("Border", true);//Toggleclass () The second parameter is a true value added $$("a"). Toggle (function (index,currentclass) { - - if(index%2==0){ the return "Border"; -}Else{Wuyi return "Border1"; the } - Wu }); - About E.preventdefault (); $ } - - }); - A</script> +</body> theOperation of jquery related class attributes