Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在父级中移动具有相同类的多个div_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 在父级中移动具有相同类的多个div

Javascript 在父级中移动具有相同类的多个div,javascript,jquery,html,css,Javascript,Jquery,Html,Css,因此,我的网站托管在enjin.com上,当你给用户一个带有图像的标签时,它会以他们的名字出现在论坛上,但是它是一个带有标签名的垂直列表。我想组织它,使所有标记图像显示在一行上,所有标记名称显示在其下方的水平列表上 它们使用的div标记有点像这样 <div class="tag"> <div class="tag-image"></div> <!-- If the tag lacks an image this is excluded -->

因此,我的网站托管在enjin.com上,当你给用户一个带有图像的标签时,它会以他们的名字出现在论坛上,但是它是一个带有标签名的垂直列表。我想组织它,使所有标记图像显示在一行上,所有标记名称显示在其下方的水平列表上

它们使用的div标记有点像这样

<div class="tag">
    <div class="tag-image"></div> <!-- If the tag lacks an image this is excluded -->
    <div class="tag-text">Tag Name</div> <!-- If you want the name to be hidden this is excluded -->
</div>
什么也没发生。如果我需要的话,我怀疑这个脚本应该放在head标签中才能工作。我的平台无法做到这一点,但我正在制定解决方案,因为我以前遇到过这个问题

编辑: 试图这样做:

$('.tag-image').each(function(){
    $(this).parent().find('.cell').append($(this));
});
window.addEventListener('DOMContentLoaded', moveimgs, false);
    function moveimgs(){
        $('.tag-image').each(function(){
            $(this).parent().find('.cell').append($(this));
        });
}

同样的结果。

我不确定你想做什么,但如果是这样的话,那么你应该使用表格

<table class="tag">
    <tr>
        <td><div class="tag-image">
            <img src="http://us.123rf.com/400wm/400/400/danomyte/danomyte0811/danomyte081100001/3807403-superhero-getting-ready-for-action.jpg" width="30px"/>
        </div></td>
        <td><div class="tag-text">Tag Name</div></td>
    </tr>


    <tr>
        <td><div class="tag-image">
            <img src="http://us.123rf.com/400wm/400/400/danomyte/danomyte0811/danomyte081100001/3807403-superhero-getting-ready-for-action.jpg" width="30px"/>
        </div></td>
        <td><div class="tag-text">Tag Name</div></td>
    </tr>

    <tr>
        <td><div class="tag-image">
            <img src="http://us.123rf.com/400wm/400/400/danomyte/danomyte0811/danomyte081100001/3807403-superhero-getting-ready-for-action.jpg" width="30px"/>
        </div></td>
        <td><div class="tag-text">Tag Name</div></td>
    </tr>
</table>

标签名
标签名
标签名

因此,每个带有类标记的div可以有多个子div和类标记图像,但只有一个子div和类标记文本,并且标记图像div应该水平对齐,并且始终位于标记文本div的上方?提供您想要的结构,以及有关html注释的更多细节。不知道
tagtxt
classis的隐藏标准是什么,也不完全清楚您要做什么。如果您发布更多的HTML显示前后,并显示多个应分组的图像和多个不应分组的图像,那么您很可能会得到一个真正符合您需要的答案。另外,请确保显示父结构,因为它看起来像只显示了一个项,而不是多个项,也不是多个父项。否,具有“tag”类的每个div只能有一个标记图像和一个标记文本。但除此之外,你已经知道了。你说你知道如何附加…你应该先尝试一下,并提供你的尝试…从中学习。这就是这里的洞点…给一个人一条鱼,或者教他钓鱼?对不起,我不能用桌子。我有幸能够使用js,但我不能切换到表,除非我更多地使用js将其转换为表。我无法改变论坛的工作方式,也无法生成所有这些内容。主机的cms已全部锁定。