button
元素反弹?我们用$("button")
选择它们,然后我们用.addClass("animated bounce");
为它们添加了一些CSS类.addClass("animated bounce");
。您刚刚使用了jQuery的.addClass()
函数,它允许您向元素添加类。首先,让我们使用$(".well")
选择器将你的div
元素与类well
对准。请注意,就像CSS声明一样,您键入一个.
在课堂名称之前。然后使用jQuery的.addClass()
函数中添加类animated
和shake
。例如,您可以通过将以下内容添加到document ready function
来创建具有类text-primary
shake的所有元素: $(".text-primary").addClass("animated shake");
addClass()
函数为类赋予animated
并使用类well
shake
所有元素。
testString: 'assert($(".well").hasClass("animated") && $(".well").hasClass("shake"), "Use the jQuery addClass()
function to give the classes animated
and shake
to all your elements with the class well
.");'
- text: 只使用jQuery将这些类添加到元素中。
testString: 'assert(!code.match(/class\.\*animated/g), "Only use jQuery to add these classes to the element.");'
```