Hide Button with empty field

I have a submit button that I would like to hide until validations has validated fields are not empty. I know through JS that I can write function as

$(document).ready(function() {

if(!$('input').val()){
    $('#button').hide();
}
else {
    $('button').show();
}
});

How do I accomplish this through dynamic attributes? 
Community Page
Last updated: