单击时如何更改按钮文本? [英] How to change button text when clicked?
本文介绍了单击时如何更改按钮文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的网站不在Squarespace上运行,我有一个显示"DELIVER ME"的按钮,但是当您单击它时,我希望它在下一页加载时显示"G.T.F.O".
I am running my website off of squarespace and I have a button that says "DELIVER ME" but when you click it, I want it to say "G.T.F.O" while the next page loads.
我没有为此的代码,需要帮助来编写.
I don't have a code for this and need help writing one.
function changeButtonText(DELIVER ME, G.T.F.O.){
if (this.value== "DELIVER ME"){
this.value = "G.T.F.O.";
} else {
this.value = "DELIVER ME";
}
}
changeButtonText();
我希望按钮说出"DELIVER ME",直到您单击它,然后单击它,然后说"G.T.F.O.".
I want the button to say "DELIVER ME" until you click it, then once you click it the button will say "G.T.F.O."
推荐答案
<button type="button" id="btn" onclick=changeButtonText()>deliver me</button>
<script>
function changeButtonText(){
document.getElementById("btn").innerHTML = "GTFO";
}
</script>
这篇关于单击时如何更改按钮文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文