如何使用 jQuery 隐藏页面上的某些元素

发布于 2024-08-28 17:38:34 字数 2096 浏览 7 评论 0原文

我正在尝试实现类似于分面搜索的东西。我的数据是一系列对象和关系。这个想法是,您单击一个对象(在本例中为“95 条论纲”),然后显示可能的关系,在本例中为“作者”,然后单击关系会显示与该关系匹配的对象,在本例中为“Martin Luther”。

我对对象和关系(谓词)的单击效果很好,我需要做的是允许用户单击对象或关系并删除从其扩展的所有内容,

这就是我在对象或关系“标签”时添加的想法。单击(每次添加另一个对象或关系时,我都会增加名为“level”的全局属性):

if($(".objHolder,. preHolder").filter("[level>'"+level+"']").filter("[holderId='"+holderId+"']").length) 
{   
    $(".objHolder,. preHolder").filter("[level>'"+level+"']").filter("[holderId='"+holderId+"']").remove();
}

<table border="0" cellpadding="4" cellspacing="2">
  <tbody>
    <tr>
      <td class="objHolder" objid="1" holderid="1" level="1">
        <table border="0" cellpadding="4" cellspacing="2">
          <tbody>
            <tr class="objItemRow" objid="1" holderid="1" level="1">
              <td class="objItem" objid="1" holderid="1" level="2" bgcolor="#eeeeee" nowrap="nowrap">95 Theses</td>
            </tr>
          </tbody>
        </table>
      </td>
      <td><img src="images/right.jpg" alt="" height="10" width="16"></td>
      <td class="preHolder" level="2" holderid="1">
        <table border="0" cellpadding="4" cellspacing="2">
          <tbody>
            <tr>
              <td class="preItem" level="3" subid="1" preid="1" holderid="1" bgcolor="#eeeeee" nowrap="nowrap">author</td>
            </tr>
          </tbody>
        </table>
      </td>
      <td><img src="images/right.jpg" alt="" height="10" width="16"></td>
      <td class="objHolder" level="3" holderid="1">
        <table border="0" cellpadding="4" cellspacing="2">
          <tbody>
            <tr>
              <td class="objItem" level="4" objid="3" holderid="1" bgcolor="#eeeeee" nowrap="nowrap">Martin Luther</td>
            </tr>
          </tbody>
        </table>
      </td>
    </tr>
  </tbody>
</table>

I am trying to implement something that is similar to a faceted search. My data is a series of objects and relationships. The idea is that you click an object (in this case "95 Theses" and then the possibly relationships are displayed, in this case "author" and clicking the relationship shows the object that matches the relationship, in this case "Martin Luther".

My clicking of objects and relationsips (predicates) works fine. What I need to do is allow users to click an object or relationship and have all those that extend from it removed.

This is what I thought of adding when a object or relationship 'tag' is clicked (every time I add another object or relationship I increment the global attribute called 'level'):

if($(".objHolder,. preHolder").filter("[level>'"+level+"']").filter("[holderId='"+holderId+"']").length) 
{   
    $(".objHolder,. preHolder").filter("[level>'"+level+"']").filter("[holderId='"+holderId+"']").remove();
}

<table border="0" cellpadding="4" cellspacing="2">
  <tbody>
    <tr>
      <td class="objHolder" objid="1" holderid="1" level="1">
        <table border="0" cellpadding="4" cellspacing="2">
          <tbody>
            <tr class="objItemRow" objid="1" holderid="1" level="1">
              <td class="objItem" objid="1" holderid="1" level="2" bgcolor="#eeeeee" nowrap="nowrap">95 Theses</td>
            </tr>
          </tbody>
        </table>
      </td>
      <td><img src="images/right.jpg" alt="" height="10" width="16"></td>
      <td class="preHolder" level="2" holderid="1">
        <table border="0" cellpadding="4" cellspacing="2">
          <tbody>
            <tr>
              <td class="preItem" level="3" subid="1" preid="1" holderid="1" bgcolor="#eeeeee" nowrap="nowrap">author</td>
            </tr>
          </tbody>
        </table>
      </td>
      <td><img src="images/right.jpg" alt="" height="10" width="16"></td>
      <td class="objHolder" level="3" holderid="1">
        <table border="0" cellpadding="4" cellspacing="2">
          <tbody>
            <tr>
              <td class="objItem" level="4" objid="3" holderid="1" bgcolor="#eeeeee" nowrap="nowrap">Martin Luther</td>
            </tr>
          </tbody>
        </table>
      </td>
    </tr>
  </tbody>
</table>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乙白 2024-09-04 17:38:34

$(".objHolder,.preHolder") 是否用于将两个不同的类选择到一个数组中?

如果是,请尝试 $(".objHolder").add(".preHolder") 并以任何方式编写 . 和类名称 (preHolder ) 没有空格!

Is $(".objHolder,. preHolder") for selection two different classes into one array?

If yes, try $(".objHolder").add(".preHolder") and any way write . and class name (preHolder) without a space!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文