jQuery fue creado en 2006 por John Resig. Fue diseñado para manejar incompatibilidades del navegador y simplificar la manipulación HTML DOM, el manejo de eventos, las animaciones y Ajax.
Durante más de 10 años, jQuery ha sido la biblioteca de JavaScript más popular del mundo.
Sin embargo, después de la versión 5 de JavaScript (2009), la mayoría de las utilidades de jQuery se pueden resolver con unas pocas líneas de JavaScript estándar:
Eliminar un elemento HTML:
$("#id02").remove();
Pruébelo usted mismo →
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
</head>
<body>
<h2>Remove an HTML Element</h2>
<p id="id01">Hello World!</p>
<p id="id02">Hello Sweden!</p>
<script>
$(document).ready(function() {
$("#id02").remove();
});
</script>
</body>
</html>
document.getElementById("id02").remove();
Pruébelo usted mismo →
<!DOCTYPE html>
<html>
<body>
<h2>Remove an HTML Element</h2>
<p id="id01">Hello World!</p>
<p id="id02">Hello Sweden!</p>
<script>
document.getElementById("id02").remove();
</script>
</body>
</html>
Devuelve el padre de un elemento HTML:
myParent = $("#02").parent().prop("nodeName"); ;
Pruébelo usted mismo →
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
</head>
<body>
<h2>Getting Parent HTML Element</h2>
<p id="01">Hello World!</p>
<p id="02">Hello Sweden!</p>
<p id="demo"></p>
<script>
$(document).ready(function() {
$("#demo").text($("#02").parent().prop("nodeName"));
});
</script>
</body>
</html>
myParent = document.getElementById("02").parentNode.nodeName;
Pruébelo usted mismo →
<!DOCTYPE html>
<html>
<body>
<h2>Get Parent HTML Element</h2>
<p id="01">Hello World!</p>
<p id="02">Hello Sweden!</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = document.getElementById("02").parentNode.nodeName;
</script>
</body>
</html>