.html()
que le permite agregar etiquetas HTML y texto dentro de un elemento. Cualquier contenido previamente dentro del elemento será reemplazado completamente con el contenido que proporcione utilizando esta función. Así es como reescribiría y enfatizaría el texto de nuestro encabezado: $("h3").html("<em>jQuery Playground</em>");
jQuery también tiene una función similar llamada .text()
que solo altera el texto sin agregar etiquetas. En otras palabras, esta función no evaluará ninguna etiqueta HTML que se le pase, sino que la tratará como el texto con el que desea reemplazar el contenido existente. Cambia el botón con id target4
enfatizando su texto. Consulte este enlace para saber más sobre la diferencia entre <i>
y <em>
y sus usos. Tenga en cuenta que si bien la etiqueta <i>
se ha usado tradicionalmente para enfatizar el texto, desde entonces se ha utilizado como etiqueta para los iconos. La etiqueta <em>
ahora es ampliamente aceptada como la etiqueta de énfasis. Tampoco funcionará para este desafío. target4
el texto en su botón target4
agregando etiquetas HTML.
testString: 'assert.isTrue((/|\s*#target4\s*<\/em>|<\/i>/gi).test($("#target4").html()), "Emphasize the text in your target4
button by adding HTML tags.");'
- text: Asegúrate de que el texto no haya cambiado.
testString: 'assert($("#target4") && $("#target4").text().trim() === "#target4", "Make sure the text is otherwise unchanged.");'
- text: No alteres ningún otro texto.
testString: 'assert.isFalse((/|/gi).test($("h3").html()), "Do not alter any other text.");'
- text: Asegúrese de que está utilizando .html()
y no .text()
.
testString: 'assert(code.match(/\.html\(/g), "Make sure you are using .html()
and not .text()
.");'
- text: Asegúrese de seleccionar button id="target4"
con jQuery.
testString: 'assert(code.match(/\$\(\s*?(\"|\")#target4(\"|\")\s*?\)\.html\(/), "Make sure to select button id="target4"
with jQuery.");'
```