<sectionid="description"> Ahora conoce tres formas de apuntar elementos: por tipo: <code>$("button")</code> , por clase: <code>$(".btn")</code> , y por id <code>$("#target1")</code> . Aunque es posible agregar varias clases en una sola llamada <code>.addClass()</code> , vamos a agregarlas al mismo elemento de <em>tres maneras diferentes</em> . Usando <code>.addClass()</code> , agregue solo una clase a la vez al mismo elemento, de tres formas diferentes: agregue la clase <code>animated</code> a todos los elementos con el <code>button</code> tipo. Agregue la clase <code>shake</code> a todos los botones con la clase <code>.btn</code> . Agregue la clase <code>btn-primary</code> al botón con id <code>#target1</code> . <strong>Nota</strong><br> Solo debes apuntar a un elemento y agregar solo una clase a la vez. En total, sus tres selectores individuales terminarán agregando las tres clases <code>shake</code> , <code>animated</code> y <code>btn-primary</code> a <code>#target1</code> . </section>
testString: 'assert(code.match(/\$\s*?\(\s*?(?:"|")\s*?#target1\s*?(?:"|")/gi), "Use the <code>$("#target1")</code> selector.");'
- text: Solo agrega una clase con cada uno de tus tres selectores.
testString: 'assert(code.match(/addClass/g) && code.match(/addClass\s*?\(\s*?("|")\s*?[\w-]+\s*?\1\s*?\)/g).length > 2, "Only add one class with each of your three selectors.");'
testString: 'assert($("#target1").hasClass("animated") && $("#target1").hasClass("shake") && $("#target1").hasClass("btn-primary"), "Your <code>#target1</code> element should have the classes <code>animated</code>‚<code>shake</code> and <code>btn-primary</code>.");'
- text: Solo use jQuery para agregar estas clases al elemento.
testString: 'assert(!code.match(/class.*animated/g), "Only use jQuery to add these classes to the element.");'