I apologize for such a Nubian question, but how to insert a variable here?

var color $(this).removeClass().addClass(ПЕРЕМЕННАЯ_color); 

    2 answers 2

      var color = "black"; $(this).removeClass(color).addClass(color); 
    • one
      Some kind of nonsense, and yes even recognized, as the best answer ... Not to mention the fact that it’s not a docking with a question, but also a "transfusion from a sieve." > Remove the black class in order to add it immediately. - Deonis
    • The question seemed to be how to use a variable in a function call and not how to do it. My example shows how the removeClass () and addClass () functions get a variable - Nord001
    • one
      @ Nord001, let's not juggle. Quote> how to insert a variable here And specify the place where you need to "insert" the variable - Deonis
    • Well - hinting that this is my cartoon? Or what? - Nord001
    • hashcode.ru/questions/132335/ ... This question does not bother you? - Nord001

    And maybe the question was meant:

     var peremennaya = 'kakoyeto_zhachenie'; $(this).removeClass('kakoyto_class').addClass(peremennaya+'_color'); 
    • yes ... it is a pity that we are not psychics ... - oneboy
    • Or maybe I wanted something like ... var variable = "lala"; var lala_color = "tada"; ... .... addClass (eval (variable + "_ color))? :-) - Chad