我在页面上一起显示了以下 DIV 元素:
<div><a href="javascript:;" id="awesome-button" style="visibility:hidden">This Link Shows Up First</a></div>
<div style="display:none; id:showUpAfterAwesomeButtonIsClicked;"><a href="javascript:;" onclick="someFunction();">This is the value that should show up after the link above is clicked.</a></div>
如您所见,This Link Shows Up First
文本最初在页面加载时显示。我有以下 javascript 确定用户是否单击了This Link Shows Up First
文本。目标是在隐藏的情况下显示This is the value that should show up after the link above is clicked
div 。awesome-button
custom.valueAwesome = function() {
var awesomeButton = document.getElementById('awesome-button');
awesomeButton.style.visibility = 'hidden';
document.getElementById("showUpAfterAwesomeButtonIsClicked").style.display = '';
gadash.executeCommandQueue();
};
showUpAfterAwesomeButtonIsClicked
我已经测试了这个脚本,当用户单击链接时,它成功地将链接的状态更改为隐藏。这让我相信需要更新的连接与这一行有关:
document.getElementById("showUpAfterAwesomeButtonIsClicked").style.display = '';
我已经尝试了这条线的几种变体。有没有更好的方法来实现这个结果?谢谢。