首页 \ 问答 \ 如何将
    添加到一组li中(How to add
      to a group of li)

如何将
    添加到一组li中(How to add
      to a group of li)

我有一些标记如下

<div class="col-sm-4 col-md-4 col-lg-4 someclass">

     <li id="app-105">Find Friends</li>
     <li id="app-107">Buy Tickets,Pay Cover Charges</li>
     <li id="app-3">Pre-purchase bottle service</li>
     <li id="app-4">Book VIP Services</li>
     <li id="app-5">Buy Merchandise</li>
     <li id="app-6">Toast Friends worldwide</li>
     <li id="app-7">Notify Services &amp; split the tab</li>

</div>

现在我想这样做

<div class="col-sm-4 col-md-4 col-lg-4 someclass">

    <ul class="ajax-terms">

      <li id="app-105">Find Friends</li>
      <li id="app-107">Buy Tickets,Pay Cover Charges</li>
      <li id="app-3">Pre-purchase bottle service</li>
      <li id="app-4">Book VIP Services</li>
      <li id="app-5">Buy Merchandise</li>
      <li id="app-6">Toast Friends worldwide</li>
      <li id="app-7">Notify Services &amp; split the tab</li>

   </ul>

</div>

注意:像app-105这样的ID可能会像app-200app-201等动态变化,以后可以添加更多的li

如何使用纯JavaScript或jQuery解决它?

任何帮助开始将不胜感激。


I have some markup like below

<div class="col-sm-4 col-md-4 col-lg-4 someclass">

     <li id="app-105">Find Friends</li>
     <li id="app-107">Buy Tickets,Pay Cover Charges</li>
     <li id="app-3">Pre-purchase bottle service</li>
     <li id="app-4">Book VIP Services</li>
     <li id="app-5">Buy Merchandise</li>
     <li id="app-6">Toast Friends worldwide</li>
     <li id="app-7">Notify Services &amp; split the tab</li>

</div>

Now I want to make it like this

<div class="col-sm-4 col-md-4 col-lg-4 someclass">

    <ul class="ajax-terms">

      <li id="app-105">Find Friends</li>
      <li id="app-107">Buy Tickets,Pay Cover Charges</li>
      <li id="app-3">Pre-purchase bottle service</li>
      <li id="app-4">Book VIP Services</li>
      <li id="app-5">Buy Merchandise</li>
      <li id="app-6">Toast Friends worldwide</li>
      <li id="app-7">Notify Services &amp; split the tab</li>

   </ul>

</div>

Note: Ids like app-105 may change dynamically like app-200,app-201 etc. and more li's can be added in future.

How can I solve it with plain JavaScript or jQuery?

Any help to start will be appreciated.


原文:https://stackoverflow.com/questions/33366812
更新时间:2023-08-01 15:08

最满意答案

您可以使用连接组件标签

在Matlab中,假设你的矩阵只包含0和1(或者你可以这样做),你可以使用bwlabel

L = bwlabel(data, 8)

现在L将是一个与标签1, 2, 3...相同大小的矩阵代替1。

作为第二个参数的8表示组件的连接性。 4-connected意味着只有在方形的左侧,右侧,上方或下方,一个方形连接到另一个方格。 8-connected意味着如果正方形对角线相邻,也会连接正方形,如样本的右下角。 8是默认设置,您可以将其删除,但是如果您需要它在将来表现不同,您应该注意区别。


You can use connected component labeling.

In Matlab, assuming your matrix contains only 0 and 1 (or you can make it so), you would use bwlabel.

L = bwlabel(data, 8)

Now L will be a matrix the same size as data with labels 1, 2, 3... in place of the 1's.

The 8 as the second parameter denotes the connectivity of the components. 4-connected would mean that one square is connected to the other only if it is to the left, right, above or below the square. 8-connected means that squares are also connected if they are adjacent diagonally, as in the bottom-right of your sample. 8 is the default, and you can leave it out, but you should be aware of the distinction in case you need it to behave differently in the future.

相关问答

更多
  • 您可以使用连接组件标签 。 在Matlab中,假设你的矩阵只包含0和1(或者你可以这样做),你可以使用bwlabel 。 L = bwlabel(data, 8) 现在L将是一个与标签1, 2, 3...相同大小的矩阵代替1。 作为第二个参数的8表示组件的连接性。 4-connected意味着只有在方形的左侧,右侧,上方或下方,一个方形连接到另一个方格。 8-connected意味着如果正方形对角线相邻,也会连接正方形,如样本的右下角。 8是默认设置,您可以将其删除,但是如果您需要它在将来表现不同,您应该 ...
  • RGB = [255 0; 0 255; 0 0]; % red and green rectSize = 50; imshow([repmat(reshape(RGB(:,1),[1 1 3]),[rectSize rectSize]) repmat(reshape(RGB(:,2),[1 1 3]),[rectSize rectSize])]); RGB = [255 0; 0 255; 0 0]; % red and green rectSize = 50; imshow([repmat(re ...
  • 由于您是机器学习/数据挖掘的新手,您不应该解决这些高级问题。 毕竟,你正在使用的数据被用于比赛(KDD Cup'99),所以不要指望它很容易! 除了数据是用于分类任务(监督式学习),其目标是预测正确的类别(不良/良好的连接)。 您似乎对聚类(无监督学习)感兴趣,这通常更困难。 这类数据集需要进行大量的预处理和巧妙的特征提取。 人们通常使用领域知识(网络入侵检测)从原始数据中获得更好的特征。直接应用简单算法(如K均值)通常会产生较差的结果。 对于初学者,您需要将属性标准化为相同的比例:在计算欧几里得距离时,作 ...
  • 您获得的值是这些对象的精确质心。 所以你可能想要定义你期望得到的结果。 为了使这一点更加清晰,我已经为矩阵中的对象着色了。 通过笛卡尔网格上的对称性,质心的左右两侧应该有相同数量的点,质心上方/下方应该相同。 我绘制了一个彩色物体的图形,以及代表水平和垂直中心线的线条。 这些是线条,我们在它们的左/右(或上/下)具有相同数量的点,它们是某个对象的一部分。 它们的交点是质心,因此您可以看到质心位于(8, 14) 8,14)的物体5(蓝色(8, 14) 。 对于其他两个对象,这些中心线不位于您拥有的整数网格上: ...
  • 这是使用ismember和sort的解决方案: E = [ ... 1 2; 3 4; 2 5; 5 3]; [~,M_IDX] = ismember(E(:,1),E(:,2)); [~,S_IDX] = sort(M_IDX); G = E(S_IDX,:) G = 1 2 2 5 5 3 3 4 请注意,这假设图表的表现非常好,即从起始节点到结束节点只有一条路径,并且该路径遍历所有边缘。 Here's a solu ...
  • 你需要的是一个可以处理字符串的距离函数。 查看Levenshtein距离 (编辑距离)。 那里有很多实现: Wikibooks.org FEX上的“字符串间距”的计算 或者,你应该提取一些有趣的特征(例如:元音的数量,字符串的长度等等)来构建一个向量空间表示,然后你可以在新的上应用任何常用的距离测量(欧几里德,...)表示。 编辑 您的代码的问题是LINKAGE期望输入距离格式与PDIST的格式相匹配,即对应于1-vs-2,1-vs-3,2-vs-3等顺序的观察对的行向量..它基本上是完整距离矩阵的下半部分 ...
  • 你应该在第一步有512个维度向量,每帧一个这样的向量,或者等效地是512×n矩阵。 然后在第二步中我不认为他们使用普通的内置层次聚类 - 这不是时间意识,并且不会产生间隔,加上它会扩展O(n ^ 3)这真的很糟糕 - 但相反他们使用自定义聚类算法,灵感来自层次聚类和使用Ward的链接,但它按时间间隔运行; 从单帧开始,但只加入相邻的区间 ,而不是像常规层次聚类那样的任意区间。 You should have 512 dimensional vectors at the first step, one suc ...
  • 如果你有图像处理工具箱,我也可以通过imfindcircles建议圆形霍夫变换 。 但是,这至少需要版本R2012a,所以如果你没有它,这将不起作用。 为了完整起见,我假设你拥有它。 如果您想保持图像不变,这是一个很好的方法。 如果您不知道Hough变换是什么,它是一种在图像中查找直线的方法。 圆形霍夫变换是一种特殊情况,旨在寻找图像中的圆圈。 圆形霍夫变换的附加优点是它能够检测图像中的部分圆。 这意味着图像中连接的那些区域,我们可以将它们检测为单独的圆圈。 你如何称呼imfindcircles是以下列方式 ...
  • 确保使用MATLAB兼容的JRE / JDK编译java文件。 据我所知,MATLAB与Java 7无法正常工作,所以暂时坚持使用Java 6 ...... 有几个环境变量会影响MATLAB。 就我而言,我有: JAVA_HOME = C:\Program Files\Java\jdk1.6.0_32 MATLAB_JAVA = C:\Program Files\Java\jre6 PATH = ...;C:\Program Files\Java\jdk1.6.0_32\bin 这是我刚刚做的一个简单的测 ...
  • 从hclust文档中, hc$merge给出了用于创建聚类的索引,而hc$height给出了索引之间的距离。 使用USArrests作为样本数据集: hc<- hclust(dist(USArrests), method="complete") data.mat<-data.matrix(data.frame(hc$merge,hc$height)) > head(data.mat) X1 X2 hc.height [1,] -15 -29 2.291288 [2,] -17 -26 3 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)