gpt4 book ai didi

javascript - 单击按钮更改文本

转载 作者:行者123 更新时间:2023-11-28 18:08:24 24 4
gpt4 key购买 nike

我试图让按钮在单击时更改文本,同时它也会打开菜单。菜单正在工作并且正在打开 onclick,但按钮上的文本没有打开。

是否可能对打开菜单的部分进行故障排除?我找不到为什么它不起作用。

按钮

<button type="button" id="showRight" onClick="click()">Tools</button>  

脚本:

<script>
var menuLeft = document.getElementById( 'cbp-spmenu-s1' ),
menuRight = document.getElementById( 'cbp-spmenu-s2' ),
menuTop = document.getElementById( 'cbp-spmenu-s3' ),
menuBottom = document.getElementById( 'cbp-spmenu-s4' ),
showRight = document.getElementById( 'showRight' ),
body = document.body;

showRight.onclick = function() {
classie.toggle( this, 'active' );
classie.toggle( menuRight, 'cbp-spmenu-open' );
};

function click()
{
var change = document.getElementById("showRight");
if (change.value == "Tools")
{
change.value = "X";
}
else
{
change.value = "Tools";
}
}
</script>

最佳答案

这不是 change.value,而是 change.textContentchange.innerText(如果您愿意的话)。

关于javascript - 单击按钮更改文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42161797/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com