【发布时间】:2020-07-10 07:10:07
【问题描述】:
我在我们的 Shopify 网站上创建了一个带有关闭按钮的自定义公告栏。 以下脚本代码关闭栏:
<script>
$( document ).ready(function() {
if ($('.announcement-bar').length){
$( '.x' ).click(function() {
$(".announcement-bar").remove();
$("body").addClass("no-announcement-bar");
});
}
});
</script>
如果用户决定刷新页面或打开网站上的其他页面,我需要它保持关闭状态。公告栏不断恢复。 我想实现一个主题设置复选框,例如:
{%- if section.settings.show_everytime == false -%}
then don't show the bar after close
{%- else -%}
show bar everytime
我知道如何实现这一点,但不知道如何使用该 If 语句执行脚本来管理点击事件。
任何帮助表示赞赏。
【问题讨论】: