Inline Edit Field
A profile value with an inline edit-and-save interaction.
Requires Bootstrap 5. Add the CDN tags below to your page (styles in
<head>, scripts before </body>). The downloaded file already includes them.<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script><div class="card border-0 shadow-sm" style="max-width:340px"><div class="card-body">
<h6 class="fw-bold mb-2">Profile</h6>
<div class="d-flex justify-content-between align-items-center py-2 border-bottom"><span class="text-secondary small">Name</span><span class="d-flex gap-2 align-items-center"><span id="edVal">Jordan Smith</span><button class="btn btn-sm btn-link p-0 text-decoration-none" id="edBtn">edit</button></span></div>
<div id="edForm" style="display:none" class="mt-2"><div class="input-group input-group-sm"><input class="form-control" id="edInput"><button class="btn btn-primary" id="edSave">Save</button></div></div>
</div></div>var val=document.getElementById('edVal'),form=document.getElementById('edForm'),inp=document.getElementById('edInput');
document.getElementById('edBtn').onclick=function(){inp.value=val.textContent;form.style.display='block'};
document.getElementById('edSave').onclick=function(){if(inp.value.trim())val.textContent=inp.value.trim();form.style.display='none'};Free to use.This component uses Bootstrap 5 (linked above). Copy any file, or download a ready-to-open .html page with the CDN links already included.