標籤:style blog http color java io cti ar
- jQuery 點擊變色效果的代碼實現,點擊後文字所在方框的背景會變色,至於變成什麼顏色,隨你了,本代碼的重點是效果的實現,並不局限於細節。
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><title>接觸角測定儀</title></head><style type="text/css"> #t1,#t2,#t3,#t4{ height:30px; width:50px; background-color:#33FFFF; float:left; margin-left:50px; text-align:center; } .active{background-color:#FC5A0A!important;} </style> <script type="text/javascript" src="http://www.codefans.net/ajaxjs/jquery1.3.2.js"></script> <script type="text/javascript"> jQuery(function(){ var list = jQuery(‘#t1, #t2, #t3, #t4‘); list.click(function(){ list.removeClass(‘active‘); jQuery(this).addClass(‘active‘); return false; }); }); </script> <body> <div id="t1"><a href="#">1</a></div> <div id="t2"><a href="#">2</a></div> <div id="t3"><a href="#">3</a></div> <div id="t4"><a href="#">4</a></div> </body></html>