Skip to content
Justice Tech School

Get and Set Content

text, html and val read or write content. With an argument they set, without they get. Use text for user data to avoid injecting HTML.

Example
const t = $('#a').text();
$('#a').html('<b>Bold</b>');
$('#name').val('Ada');

Exercise

Read an input value.

$('#name').()

Quiz Test

Which is safest for user text?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.