text(), html() and val()

With no argument they read, with an argument they write. Use text() for user content, never html().

jQuery · text(), html() and val()Beginner
$('#title').text('Hello');                 // set text (safe)
const t = $('#title').text();              // read text

$('#box').html('<b>Bold</b>');             // set HTML (only for your own markup)

$('#name').val('Ali');                     // set input value
const name = $('#name').val();             // read input value
texthtmlvalget set