JQuery append 元素删除所有 html dom 元素 [英] JQuery append element removes all html dom elements

查看:39
本文介绍了JQuery append 元素删除所有 html dom 元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个过滤系统设置,但我在使用 jquery .append 时遇到了困难.

I have a filter system setup and I'm struggling with jquery .append.

当用户与过滤系统交互时,可见结果从dom中移除,然后均匀分布在<div class="col-1">... <div class="col-2">... <div class="col-3">...

When the user interacts with the filter system, the visible results are removed from the dom and then distributed evenly in <div class="col-1"> ... <div class="col-2">... <div class="col-3">...

这样做是因为页面以垂直方式输出人员,但过滤必须水平重新排序.当您使用第一个过滤器时,您就会明白我的意思.

It's done this way because the page outputs staff in a vertical manner, but the filtering must reorder horizontally. You'll see what I mean when you use the first filter.

请查看此页面:演示页面

  1. 点击活动赞助商
  2. 然后点击东

我说的函数是reflowVisibleResults()基本上可见的结果被复制到一个数组,然后从文档中删除,然后在 col-1,col-2,col-3 中从左到右重排

The function that I'm talking about is reflowVisibleResults() Basically visible results are copied to an array and then removed from the document only to be then reflowed left to right in col-1,col-2,col-3

整个页面仅替换为一个电话号码.如果您转到第 917 行并切换上面的行,它会按预期工作.我只是不知道如何从 jquery 对象数组中实际输出 html.

The whole page is replaced with just a phone number. If you go to line 917 and switch the above line over it works as expected. I just can't figure out how to actually output html from an array of jquery objects.

推荐答案

同意 Parker 的观点,您的代码似乎过于复杂.这里是我将如何做的快速示例.

Agree with Parker, you code seems way overcomplicated for what it needs to be. Here is quick sample of how I would do it.

我相信它可以稍微优化和打磨,但这应该足以让您走上正确的道路.

I am sure it can be optimized and polished quiet a bit, but that should be enough to get you on the right path.

这篇关于JQuery append 元素删除所有 html dom 元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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