document ready function
. Agora vamos escrever nossa primeira declaração jQuery. Todas as funções do jQuery começam com um $
, geralmente chamado de dollar sign operator
, ou bling
. Muitas vezes, o jQuery seleciona um elemento HTML com um selector
e faz algo com esse elemento. Por exemplo, vamos fazer todos os seus elementos de button
saltarem. Basta adicionar este código dentro da função pronta para o seu documento: $("button").addClass("animated bounce");
Observe que já incluímos a biblioteca jQuery e a biblioteca Animate.css em segundo plano para que você possa usá-las no editor. Então você está usando o jQuery para aplicar a classe de bounce
do Animate.css aos seus elementos de button
. addClass()
do jQuery para dar as classes animated
e bounce
para seus elementos de button
.
testString: 'assert($("button").hasClass("animated") && $("button").hasClass("bounce"), "Use the jQuery addClass()
function to give the classes animated
and bounce
to your button
elements.");'
- text: Use apenas o jQuery para adicionar essas cores ao elemento.
testString: 'assert(!code.match(/class.*animated/g), "Only use jQuery to add these colors to the element.");'
- text: Seu código jQuery deve estar dentro do $(document).ready();
função.
testString: 'assert(code.match(/\$\(document\)\.ready\(function.*(\s|\n)*.*button.*.addClass.*\);/g), "Your jQuery code should be within the $(document).ready();
function.");'
```