Javascript 在Oracle jet中隐藏一个div

Javascript 在Oracle jet中隐藏一个div,javascript,jquery,html,oracle-jet,Javascript,Jquery,Html,Oracle Jet,我正在创建一个Oracle Jet应用程序,其中我需要使用ojet列表。我从RESTAPI动态调用数据。 下面是列表视图的屏幕截图- 如您所见,我有一些值,即子类别、视图和更改%。问题是我只能隐藏第一个元素的div,即咨询。下面是我调用RESTAPI的JS代码和隐藏div的条件 function practiceData() { $.getJSON("REST API").then(function (dataset) { $.each(dataset,

我正在创建一个Oracle Jet应用程序,其中我需要使用ojet列表。我从RESTAPI动态调用数据。 下面是列表视图的屏幕截图-

如您所见,我有一些值,即子类别、视图和更改%。问题是我只能隐藏第一个元素的div,即咨询。下面是我调用RESTAPI的JS代码和隐藏div的条件

function practiceData() {
        $.getJSON("REST API").then(function (dataset) {

          $.each(dataset, function (index, value) {
            data5.push(value); // PUSH THE VALUES INSIDE THE ARRAY.
            arrow.push(value.change);
            console.dir("data",data5)
          console.log("value",value.change)
          console.log("arrow", arrow);
          arrow.forEach(function(value)
          {
              if (value == 0) {
                document.getElementById("triangle-up-small").style.display = 'none';
                document.getElementById("triangle-down-small").style.display = 'none';
                console.log("rgjak");
                console.log(value);
              } else if (value < 0) {

              //  $("#triangle-up-small").hide();
                console.log("hcdsb");
                console.log(value);
                document.getElementById("triangle-up-small").style.display = 'none';

              }
              else{
                // $("#triangle-down-small").hide();
               $("#triangle-up-small").hide();
                console.log("123");
                console.log(value);
              }
            });
          });
        });

    }
所有数组值都是数字,下面是列表的HTML代码-

<oj-list-view id="listview" aria-label="simple list" data="[[dataProvider5]]">
              <template slot="itemTemplate" data-oj-as="item">
                 <!-- <span class="avatar" data-bind="style: { backgroundImage: 'url(\'../images/dvt/' + item.data.id + '.png\')' }"></span>-->

                  <div class="oj-flex ">
                <div class="oj-sm-5 oj-flex-item"><span class="name"><a id="yo"><oj-bind-text value="[[item.data.subcategory]]"></oj-bind-text></a></span></div>
                <div class="oj-sm-1 oj-flex-item"><span class="oj-text-xs oj-text-secondary-color" style="float: right;"  ><oj-bind-text value="[[item.data.count]]"></oj-bind-text>views</span></div>
                 <div class="oj-sm-1 oj-flex-item" ><div id="triangle-up-small"style="float: right;"><span  id="text-green"><oj-bind-text value="[[item.data.change]]"></oj-bind-text>%</span></div></div>
                 <div class="oj-sm-1 oj-flex-item"><div id="vl"style="float: right;"><span  id="text-green"><oj-bind-text value="[[item.data.change]]"></oj-bind-text>%</span></div></div>
                 <div class="oj-sm-1 oj-flex-item"><div id="triangle-down-small"style="float: right;"><span  id="text-red" style="margin-left: 10px;margin-top:0px;"  ><oj-bind-text value="[[item.data.change]]"></oj-bind-text>%</span></div></div>
              </div>
              </template>
          </oj-list-view>
我尝试了各种方法,非常感谢您的帮助。
提前感谢您的帮助。

您应该使用有条件地显示/隐藏元素。直接使用jQuery/DOM api与DOM交互并不被认为是最佳实践。

正如@Sumedh Chakravorty所提到的,下面是问题的工作代码

<oj-list-view id="listview" aria-label="simple list" data="[[dataProvider5]]">
              <template slot="itemTemplate" data-oj-as="item">
                 <!-- <span class="avatar" data-bind="style: { backgroundImage: 'url(\'../images/dvt/' + item.data.id + '.png\')' }"></span>-->
                 <script>

                   </script>
                  <div class="oj-flex ">
                <div class="oj-sm-5 oj-flex-item"><span class="name"><a id="yo"><oj-bind-text value="[[item.data.subcategory]]"></oj-bind-text></a></span></div>
                <div class="oj-sm-1 oj-flex-item"><span class="oj-text-xs oj-text-secondary-color" style="float: right;"  ><oj-bind-text value="[[item.data.count]]"></oj-bind-text>views</span></div>
                <oj-bind-if test="[[item.data.change == '0']]">
                 <div class="oj-sm-1 oj-flex-item"><div id="vl"style="float: right;"><span  id="text-green"><oj-bind-text value="[[item.data.change]]"></oj-bind-text>%</span></div></div>
               </oj-bind-if>
                 <oj-bind-if test="[[item.data.change < '0']]">
               <div class="oj-sm-1 oj-flex-item"><div id="triangle-down-small"style="float: right;"><span  id="text-red" style="margin-left: 10px;margin-top:0px;"  ><oj-bind-text value="[[item.data.change]]"></oj-bind-text>%</span></div></div>
             </oj-bind-if>
              </div>
              </template>
          </oj-list-view>

我刚刚尝试使用oj绑定if,但无法获得所需的输出。以下是我尝试的,``%``