What I'm trying to accomplish: I want to add a DIV after an existing DIV and assign it a specific class.
I started with this:
var myClass = "thisIsMyClass"; $(this).after("<div></div>").addClass(myClass)
The problem is that myClass is added to $ (this), and not to the newly created DIV.
So I tried:
var myClass = "thisIsMyClass"; $(this).after("<div class='" & thisIsMyClass & "'></div>")
But jQuery doesn't like it either.
I can do this, however:
$(this).after("<div class='thisIsMyClass'></div>")
jQuery is fine with this syntax. Of course, I lose the ability to pass it as a variable.
I suppose I'm doing something quite obviously wrong. But I'm at a standstill what it is.
jquery
DA
source share