I'm trying to understand how Javascript and Jquery work. I know this:
var contenido = document.getElementById("contenido");
contenido.text("Hola desde Javascript");
It's the same as this:
var contenido = $("#contenido");
contenido.text("Hola desde Jquery");
But I understand that this:
var contenido = document.getElementById("contenido");
It's the same in Jquery:
var contenido = $("#contenido")[0];
Why do you add the text without the [0]
at the end? And if I add it, it does not show me the message, why is it the same? In what moments do I have to use the [0]
at the end, an example?