2
I have 2 variables and I want to put the same concatenated in just one selector with jQuery:
I know it’s possible to do it this way:
$(".classe1, .classe2").append(...);
But I want to concatenate these two classes with a variable and put the two inside a selector more or less like this (this example is giving error):
var to = $(".meunome").attr("id");
var from = $(".amigonome").attr("id");
$(".classe1'+to+', .classe2'+from+'").append(...);
+1 Note that if there is more than one element with the class
meunome
and/or more than one with the classamigonome
, this code will only select the first of each set.– mgibsonbr