I want to change my button text as below, I have two select option, draft and publish. When I select to the draft option, button text must be change. But I can't change it without refreshing page. How can I do that ?
<body>
<button id="button" value=""></button>
<select name="select" id="draftOrPublish">
<option value="0">Draft</option>
<option value="1">Publish</option>
</select>
</body>
<script>
var draftOrPublish = $('select#draftOrPublish').val();
if (draftOrPublish == 0) {
$('button#button').text('Save as Draft')
} else if (draftOrPublish == 1) {
$('button#button').text('Publish')
}
</script>