I am currently doing a dropdown button and I would like to change the button text to the certain one when user click on it for example when user click on English, the very first button will change to the text English and so on. I have try the method below but it didn't works.
Below is my HTML code:
<div class="dropdown">
<button
onclick="myFunction();hideBorder();change()"
class="dropbtn"
id="chi"
>
CHINESE
</button>
<div id="myDropdown" class="dropdown-content">
<button id="eng">ENGLISH</button>
<button id="fre">FRENCH</button>
<button id="ger">GERMAN</button>
<button id="ita">ITALIAN</button>
<button id="mal">MALAY</button>
<button id="spa">SPANISH</button>
</div>
</div>
Below is my JavaScript code:
function change() {
var btn1 = document.getElementById("chi");
var btn2 = document.getElementById("eng");
if (btn2.onclick) {
btn1.value = "ENGLISH";
}
}