代码之家  ›  专栏  ›  技术社区  ›  skr

如何使用javascript以编程方式隐藏进度条[关闭]

  •  -4
  • skr  · 技术社区  · 7 年前

    我正在使用一个进度条,我想在单击按钮时显示它。在我填充了一个列表之后,我希望进度条消失。以下是我的代码:

    <div class="progress"><div class="indeterminate"/></div>
    if (source_names_list.length == 0)
    {
      // want progress bar to appear
    
    }
    if (source_names_list.length > 0)
    {
       // want the progress bar to disappear
    }
    

    我试着设置能见度,但没用。我试着以编程方式添加进度条。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Brett Commandeur    7 年前

    您可以通过css编辑display属性。

    var source_names_list = []
    
    if (source_names_list.length == 0)
    {
      // want progress bar to appear
      document.querySelector('.progress').style.display = 'inheret'
    
    }
    if (source_names_list.length > 0)
    {
       // want the progress bar to disappear
       document.querySelector('.progress').style.display = 'none'
    }
    <div class="progress">Progress</div>
    <div class="indeterminate"/>Indeterminate</div>
    推荐文章