You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 2-ui/1-document/05-basic-dom-node-properties/article.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -397,15 +397,15 @@ Compara los dos:
397
397
<div id="elem2"></div>
398
398
399
399
<script>
400
-
let name = prompt("¿Cuál es tu nombre?", "<b>Winnie-el-pooh!</b>");
400
+
let name = prompt("¿Cuál es tu nombre?", "<b>¡Winnie-pooh!</b>");
401
401
402
402
elem1.innerHTML = name;
403
403
elem2.textContent = name;
404
404
</script>
405
405
```
406
406
407
407
1. El primer `<div>` obtiene el nombre "como HTML": todas las etiquetas se convierten en etiquetas, por lo que vemos el nombre en negrita.
408
-
2. El segundo `<div>` obtiene el nombre "como texto", así que literalmente vemos `<b>¡Winnie-el-pooh!</b>`.
408
+
2. El segundo `<div>` obtiene el nombre "como texto", así que literalmente vemos `<b>¡Winnie-pooh!</b>`.
409
409
410
410
En la mayoría de los casos, esperamos el texto de un usuario y queremos tratarlo como texto. No queremos HTML inesperado en nuestro sitio. Una asignación a `textContent` hace exactamente eso.
0 commit comments