JQuery 添加多个类
这是我目前的代码,我知道它的错误代码
$('.page-address-edit').addClass('test1').addClass('test2');
You can do
$('.page-address-edit').addClass('test1 test2');
More here:
More than one class may be added at a time, separated by a space, to the set of matched elements, like so: $("p").addClass("myClass yourClass");
More than one class may be added at a time, separated by a space, to the set of matched elements, like so:
$("p").addClass("myClass yourClass");
You can add multiple classes by separating classes names by spaces
$('.page-address-edit').addClass('test1 test2 test3');
You code is ok only except that you can't add same class test1.
test1
$('.page-address-edit').addClass('test1').addClass('test2'); //this will add test1 and test2
And you could also do
Ref- jQuery