本文實例講述了js實現選中復選框文字變色的方法。分享給大家供大家參考。具體如下:
這里實現選中復選框時,文字加上一個背景色,變通一下,還是很有用的。
運行效果如下圖所示:

在線演示地址如下:
http://demo.VeVB.COm/js/2015/js-checkbox-cha-font-color-codes/
具體代碼如下:
<html><head><title>選中復選框文字變色</title><style>.checkbox { background-Color:e-xpression(this.checked?'yellow':'buttonface');}</style></head><script>function chaCloor(field){var pig = field.checked;pig?field.nextSibling.style.backgroundColor="skyblue":field.nextSibling.style.backgroundColor="white";}</script><body><table height=48 width=136><tr> <td><input type="checkbox" onClick="chaCloor(this)"><span>網頁特效</span></td></tr><tr><td><input type="checkbox" onClick="chaCloor(this)"><span>源碼下載</span></td></tr><tr><td><input type="checkbox" onClick="chaCloor(this)"><span>編程軟件</span></td></tr></table></body></html>希望本文所述對大家的javascript程序設計有所幫助。
新聞熱點
疑難解答