<HTML><Head><MetaCharSet= "Utf-8"><title></title><Scripttype= "Text/javascript"src= "Http://www.w3school.com.cn/jquery/jquery-1.11.1.min.js"></Script><style>. BG1{Background-image:URL (images/21.jpg);background-repeat:no-repeat;Color:#0CF;}. Bg2{Background-image:URL (images/22.jpg);background-repeat:no-repeat;Color:#F00;}</style><Scripttype= "Text/javascript">//parameter para1: ID value of the element you want to hidefunctionToggle1 (para1) {if ($("#p2"). attr ("class")=="bg1") { $("#p2"). attr ("class","Bg2"); } Else { $("#p2"). attr ("class","bg1"); } $("#"+para1). Toggle ();}</Script></Head><Body><PID= "P1">Here you will see or hide</P><PID= "P2"class= "BG1"OnClick= "Toggle1 (' P1 ')"style= "height:31px">Click here to show or hide the above section and change your style (including background, fonts, etc.)</P></Body></HTML>
jquery Click Change class and Toggle