$(document).ready(function () { $("#prevAll").click(function () { $(".css").removeClass("css").prevAll().addClass("css"); }); });
<html> <head> <title>prevAll</title> </head> <body> <div> <p>This is paragraph element. This is colored.</p> <div>This is div element.</div><br> <span class="css">This is span elment.</span><br /> </div><br /> <input type="button" id="prevAll" value="prevAll" /> <input type="button" id="reset" value="Reset" onclick="location.reload()" /> </body> </html>
.css { color:Aqua; font-size:30px; }