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>
精彩评论