Jquery过滤功能

时间:2011-08-15 15:38:14

标签: jquery html filter html-lists

可能你可以帮助我。 我需要使用数组过滤

  • 标签,如下所示:

    <div id="els">
    <ul>
    <li><div>My example text<a href="javascript:void(0);">Actor</a>
             <a href="/groups/viewgroup/13-first-group">Group one</a></div></li>
    <li><div>My example text 2 <span>posted by Andrew</span></div></li>
    <li><div>My example text 3</li>
    <li><div>
             <a href="javascript:void(0);">Actor</a>
             <a href="/groups/viewgroup/1-first-group">Group one</a>
        </div>
    </li>
    <li><div><a href="javascript:void(0);">Actor</a>
             <a href="/groups/viewgroup/10-ten-group">Ten group</a>My example text. </div></li>
    <li>
       <div>6 element. <a href="/j1.5/index.php/jomsocial/63-zzz/profile">Actor</a></div>
       <div><a href="/groups/viewgroup/test/5-second-group">Group other</a></div>
    </li>
    <li>7 element.</li>
    <li><div><a href="/groups/viewgroup/test/8-second-group">First group</a></div></li>
    <li><div><a href="/groups/viewgroup/16-other-group">First group</a></div></li>
    <li><div><a href="/j1.5/index.php?option=com_community&view=groups&task=viewgroup&groupid=1&Itemid=4">My other group </a></div></li>
    </ul>
    </div>
    

    我的阵列:

    var ids = [“1”,“8”,“3”,“4”,“5”]

    我需要获取此输出(LI标签包含带有groupid的A标签在数组中):

    <div id="els">
       <ul><li><div>
             <a href="javascript:void(0);">Actor</a>
             <a href="/groups/viewgroup/1-first-group">Group one</a>
        </div>
    </li>
    <li>
       <div>6 element. <a href="/j1.5/index.php/jomsocial/63-zzz/profile">Actor</a></div>
       <div><a href="/groups/viewgroup/test/5-second-group">Group other</a></div>
    </li>
    <li><div><a href="/groups/viewgroup/test/8-second-group">First group</a></div></li>
    <li><div><a href="/j1.5/index.php?option=com_community&view=groups&task=viewgroup&groupid=4&Itemid=4">My other group </a></div></li>
    </ul>
        </div>
    

    谢谢你们!

  • 1 个答案:

    答案 0 :(得分:0)

    你能不能只使用:eq() Selector