急!!求大神,jquery怎么做点击背景颜色变,再点击再恢复

一个div,背景颜色是蓝色,点击变成红色,再点击就恢复,再变成蓝的,查了半天百度也没搜到,晕死

<!DOCTYPE html>
<html>
  <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script class="jquery library" src="/js/sandbox/jquery/jquery-1.8.2.min.js" type="text/javascript"></script>
<title>
RunJS 演示代码
</title>
<script>
$(function(){
$("div").toggle(function(){
$(this).css("backgroundColor","red");
},function(){
$(this).css("backgroundColor","blue");
});
})
</script>
  </head>
<body>
    <div style="background-color:blue">
sdfsdf
</div>
  </body>
</html>

追问

太感谢了亲,么么哒哦

温馨提示:答案为网友推荐,仅供参考
相似回答