Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

jQuery HTML

jQuery vs JavaScript

jQuery was created by John Resig in 2006 to address browser incompatibilities and simplify HTML DOM manipulation, event handling, animations, and AJAX.

For over a decade, jQuery was the most widely used JavaScript library worldwide. However, since JavaScript Version 5 (2009), many of jQuery’s features can now be accomplished with just a few lines of standard JavaScript.

Set Text Content

Set the text content of an HTML element.

jQuery

myElement.text(“Hello Sweden!”);

JavaScript

myElement.textContent = “Hello Sweden!”;

Get Text Content

Retrieve the text content of an HTML element.

jQuery

myText = $(“#02”).text();

JavaScript

myText = document.getElementById(“02”).textContent;

Set HTML Content

Set the content (HTML) of an element.

jQuery

myElement.html(“<p>Hello World</p>”);

JavaScript

myElement.innerHTML = “<p>Hello World</p>”;

Get HTML Content

Retrieve the HTML content of an element.

jQuery

content = myElement.html();

JavaScript

content = myElement.innerHTML;