ºÍÉÏÃæÒ»Ñù£¬Ö±½Óд¸öСÀý×Ó£¬¿´ÏÂÈçºÎ¿ØÖÆcssÑùʽµÄ
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JQuery¿ØÖÆcssÑùʽ</title> <style type="text/css"> .normal{ color: black; width: 150px; height: 30px; padding: 5px; } .clicked{ color: blue; width: 150px; height: 30px; padding: 5px; } </style> <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script> <script type="text/javascript"> //JQueryд·¨ $(function () { $("#changeCssBtn").click(function () { $(this).toggleClass("clicked") }); }); //´«Í³Ð´·¨ function changeCssBtnClick() { var className= document.getElementById("changeCssBtn").className; if(className=="clicked"){ document.getElementById("changeCssBtn").className="normal"; }else{ document.getElementById("changeCssBtn").className="clicked"; } } </script> </head> <body> <div > <button id="changeCssBtn" class="normal" onclick="changeCssBtnClick()">µã»÷ÐÞ¸ÄcssÑùʽ</button> </div> </body> </html> ×ܽ᣺½ñÌì¼òµ¥Ñ§Ï°Ò»ÏÂJQueryµÄ»ù´¡¼°¼òµ¥Ê¹Óá£
·ÖÏí¸øС»ï°éÃÇ£º
±¾ÎıêÇ©£º Hybrid£¬jQuery/">Hybrid£¬jQuery
Ïà¹ØÎÄÕÂ
·¢±íÆÀÂÛÔ¸ÄúµÄÿ¾äÆÀÂÛ£¬¶¼Äܸø´ó¼ÒµÄÉú»îÌíÉ«²Ê£¬´øÀ´¹²Ãù£¬´øÀ´Ë¼Ë÷£¬´øÀ´¿ìÀÖ¡£
±¾Àà×îÈÈÐÂÎÅ
¡¡