Hackforge Academy

Category: javascript

dom manipulation with jquery

Published on 30 Sep 2026

Explanation

The text() method gets or changes the text content of an element.

Code:

$('#title').text('New Title');

const value = $('#title').text();

Explanation

The html() method gets or changes the HTML content inside an element.

Code:

$('#content').html('<b>Hello</b>');

Explanation

The val() method gets or changes the value of form elements.

Code:

$('#username').val('Praveen');

const name = $('#username').val();

Explanation

The attr() method can read or modify HTML attributes.

Code:

$('#profile').attr('href', '/profile');

const url = $('#profile').attr('href');

Explanation

jQuery provides methods such as append(), prepend(), remove(), and empty() for modifying the DOM.

Code:

$('#list').append('<li>New Item</li>');
$('#list').prepend('<li>First Item</li>');
$('#old').remove();

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community