document ready function
. Ahora vamos a escribir nuestra primera declaración jQuery. Todas las funciones de jQuery comienzan con un $
, generalmente conocido como dollar sign operator
, o como bling
. jQuery a menudo selecciona un elemento HTML con un selector
, luego le hace algo a ese elemento. Por ejemplo, hagamos que todos los elementos de tus button
reboten. Solo agregue este código dentro de su función de documento listo: $("button").addClass("animated bounce");
Tenga en cuenta que ya hemos incluido la biblioteca jQuery y la biblioteca Animate.css en segundo plano para que pueda usarlas en el editor. Así que estás utilizando jQuery para aplicar la clase de bounce
Animate.css a los elementos de tu button
. addClass()
para dar a las clases animated
y bounce
en los elementos de sus 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: Solo use jQuery para agregar estos colores al elemento.
testString: 'assert(!code.match(/class.*animated/g), "Only use jQuery to add these colors to the element.");'
- text: Su código jQuery debe estar dentro de $(document).ready();
función.
testString: 'assert(code.match(/\$\(document\)\.ready\(function.*(\s|\n)*.*button.*.addClass.*\);/g), "Your jQuery code should be within the $(document).ready();
function.");'
```