Вопрос по javascript – Javascript изменить стиль Div

27

Error: User Rate Limit Exceededpart 1Error: User Rate Limit Exceededpart 2Error: User Rate Limit Exceededpart 2Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

function abc() {
    document.getElementById("test").style.color="red";
}

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded Willem D'Haeseleer

Ваш Ответ

7   ответов
1

Error: User Rate Limit Exceeded

function abc() {
    var currentColor = document.getElementById("test").style.color;

    if(currentColor == 'red'){
    document.getElementById("test").style.color="black";
    }else{
   document.getElementById("test").style.color="red";

    }
}
Error: User Rate Limit Exceeded
0

function abc(){
  var myDiv = document.getElementById("test");
  if (myDiv.className == 'alert') {
    myDiv.className = 'regular';
  } else {
    myDiv.className = 'alert';
  }
}
0
function abc() {
    var color = document.getElementById("test").style.color;
    color = (color=="red") ? "black" : "red" ;
    document.getElementById("test").style.color= color;
}
2

$(document).ready(function(){
    $('div').click(function(){
        $(this).toggleClass('clicked');
    });
});​

Error: User Rate Limit Exceeded
0

function abc(){
     var color = document.getElementById("test").style.color;
     if(color==''){
         //change
     }else{
         //change back
     }
}
41
function abc() {
    var color = document.getElementById("test").style.color;
    if (color === "red")
         document.getElementById("test").style.color="black";
    else
         document.getElementById("test").style.color="red";
}
Error: User Rate Limit ExceededsettingError: User Rate Limit ExceededgettingError: User Rate Limit Exceeded
Error: User Rate Limit Exceededcolor="black"Error: User Rate Limit Exceededcolor="red"Error: User Rate Limit Exceeded
Error: User Rate Limit ExceededcolorError: User Rate Limit ExceedednameError: User Rate Limit ExceededbobError: User Rate Limit Exceededcolor.
Error: User Rate Limit Exceeded
0

function abc() {
    var elem=document.getElementById('test'),color;
    switch(elem.style.color) {
        case('red'):
            color='black';
            break;
        case('black'):
        default:
            color='red';
    }
    elem.style.color=color;
}

Похожие вопросы