2009-08-18 Focus點選Menu的位置 1441 0 JavaScript 摘要:Focus點選Menu的位置 記錄一下<html xmlns="http://www.w3.org/1999/xhtml"> <head><title> 選單 </title><link rel="stylesheet" href="css/nav.css" /> <style type="text/css"> div { color:#004159; background-color:#DBE4E6; width:80px; } </style> <script type="text/javascript" src="js/jquery-1.2.6.min.js"></script> </head> <body> <form name="form1" method="post" action="#" id="form1"> <div><a href='#' class="tm">menu1</a></div> <div><a href='#' class="tm">menu2</a></div> <div><a href='#' class="tm">menu3</a></div> </form> </body> </html> <script type="text/javascript" language="javascript"> $().ready(function() { $(".tm").each(function(){ $(this).bind("click", function(e) { clrFocus(); //清除選項 $(this).css({ color: "yellow", background: "blue" }); //設定顏色 }); }); //清除點選資料 function clrFocus(){ $(".tm").each(function(){ $(this).css({ color: "#004159", background: "#DBE4E6" }); }); } ); </script> 回首頁