Created
June 20, 2022 14:31
-
-
Save marcus-at-localhost/c54760a91320bb6ca37eaf84485c9aaa to your computer and use it in GitHub Desktop.
[Change Button Text Depending on Another Field] #js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form> | |
<input class="kb-field-2"> | |
<button class="kb-forms-submit">A</button> | |
</form> | |
<script> | |
const field = document.getElementsByClassName('kb-field-2')[0]; | |
field.addEventListener("keyup", () => { | |
let btn = document.getElementsByClassName('kb-forms-submit')[0]; | |
if( field.value === "" ) { | |
btn.textContent = "A"; | |
}else{ | |
btn.textContent = "B"; | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment