JSFiddle - React, Tailwind, and code Playground
by blackhawx
HTML
<input type="hidden" value="home" name="newdirpath" />
<input type="button" id="btn"/>
JavaScript
$('#btn').click(function(){
var text= "helloworld";
$(this).prev('input[name=newdirpath]').attr('value',text);
});