JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" value="mot de passe" id="monInput" />
JavaScript
$('#monInput').on('focus', function () {
$(this).attr('type', 'password');
})
<input type="text" value="mot de passe" id="monInput" />
$('#monInput').on('focus', function () {
$(this).attr('type', 'password');
})