将Jquery数组元素追加到匹配的列表节点 [英] Appending Jquery array elements to matching List Nodes

查看:273
本文介绍了将Jquery数组元素追加到匹配的列表节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为此问题的扩展: jQuery返回DIV及其内容(如果包含关键字

as an extension to this problem: JQuery return DIVs and their contents only if contains a keyword

我的菜单现已分为两个部分-基于html中标记值的顶部菜单元素和底部菜单元素(现在为TOP)

My menu has been split into 2 components now - Top menu elements and bottom menu elements based on a token value in the html (for now this is TOP )

下一个问题是顶层菜单div已经包含如下所示的静态代码-如何将新创建的项目(顶层菜单)与其匹配的静态结构进行匹配.让我向您展示html:

The next issue is the top menu div already contains static code as shown below - how would it be possible to match the newly created items (for the top menu) to their matching static structure. Let me show you the html:

静态HTML

<div id="top">
    <ul>
        <li>Category 1</li>
        <li>Category 3</li>
    </ul>
</div>

此顶部元素"中的每个项目都由一个周围的div(包含一个h3标签)和一个随后的带有列表项的UL组成.

Each item in this 'topelement' consists of a surrounding div containing a h3 tag and a following UL with list items.

例如:第一个h3标签将包含文本"TOP Item 1",指示将其放置在topElement组中,而我的目标是隔离字符串"TOP"并与紧随其后的"Item 1" UL结婚到静态导航中的列表"项,因此它变成了一个子导航元素,如下所示:

As an example: The first h3 tag would contain the text 'TOP Item 1' indicating its to be put in the topElement group and my goal is to isolate the string 'TOP ' and marry the 'Item 1' UL that follows to the List item in the static nav so this becomes a sub nav element as follows:

<div id="top">
    <ul>
        <li>Category 1
            <ul><li>item 1</li><li>item 2</li><li>item 3</li></ul>
        </li>
        <li>Category 3<ul><li>item 1</li><li>item 2</li><li>item 3</li></ul>
        </li>
    </ul>
</div>

再次感谢

推荐答案

您好MrFitz:我已经对您的代码进行了必要的修改,这是链接

Hi MrFitz: I Have done the necessary modification to your code, here is the link

jsfiddle.net/HRs8N/6.

jsfiddle.net/HRs8N/6 .

快乐编码:)

这篇关于将Jquery数组元素追加到匹配的列表节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆