gpt4 book ai didi

javascript - 使用 javascript 为手机应用更改 CSS 样式

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

我有一个要在手机上显示的页面。在页面上我有一个链接单击时运行 javascript 脚本。在脚本中我想隐藏一个带有类名、内容并显示带有类名、sidebar1。我在脚本中放置了一个警报,以显示脚本在链接被点击。当我运行脚本时它会出来。现在的警报后的命令不起作用。有人可以帮忙吗?这是我的脚本:

<script type="text/javascript">
function displaymenu() {
alert("I'm the menu");
document.className.content.style.display = 'none';
document.className.sidebar1.style.display = '!important';
};

</script>

最佳答案

如果你想更新一个特定元素的样式,你应该使用元素id:

   document.getElementById("myDIV").style.display = 'none';

关于javascript - 使用 javascript 为手机应用更改 CSS 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28575601/

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