开发者

Else return for returning to originals state is not working

开发者 https://www.devze.com 2023-01-13 13:41 出处:网络
My code for changing the background color works great, but the \"else\" return does not work.Am I missi开发者_运维技巧ng something?here is what i have:

My code for changing the background color works great, but the "else" return does not work. Am I missi开发者_运维技巧ng something? here is what i have:

<script type="text/javascript">
$(document).ready(function() {
  var input = document.getElementById("test");

  input.onclick = function ()
  {
    document.getElementById("quote_input").style.backgroundColor = "#AAB3AA";
    document.getElementById("test").style.backgroundColor = "#AAB3AA";

    else {
      document.getElementById("quote_input").style.backgroundColor = "#000";
      document.getElementById("test").style.backgroundColor = "#000";

    }  
  };
});
</script>


Well sir, unless I'm mistaken, you are missing an IF statement.


you're missing the "if" part of the statement...

 <script type="text/javascript">
 $(document).ready(function() {
 var input = document.getElementById("test");

 input.onclick = function ()
 {

    if(SOME_CONDITION) {
 document.getElementById("quote_input").style.backgroundColor = "#AAB3AA";
    document.getElementById("test").style.backgroundColor = "#AAB3AA";

    } else {
 document.getElementById("quote_input").style.backgroundColor = "#000";
 document.getElementById("test").style.backgroundColor = "#000";

 }



 };});
 </script>
0

精彩评论

暂无评论...
验证码 换一张
取 消