“嵌套"使用jQuery嵌套嵌套引用(以适应tumblr 2015年9月的更新) [英] "Unnesting" Nested Blockquotes Using jQuery (to fit tumblr's September 2015 update)

查看:90
本文介绍了“嵌套"使用jQuery嵌套嵌套引用(以适应tumblr 2015年9月的更新)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为一个非常重博客的博客创建一个新的tumblr主题.根据tumblr对评论链的最新更新,一些帖子非常冗长.尽管它在我的仪表板上看起来不错,但由于嵌套的块引用,它对我的​​博客造成了严重破坏.

I'm working on a new tumblr theme for a very reblog-heavy blog. Per tumblr's latest update to the comment-chains, some posts get very lengthy. While it looks fine on my dashboard, it wrecks havoc on my blog because of the nested blockquotes.

我想模仿评论在我的仪表板上的外观,而无需用户图标等,并使用交替的颜色来帮助区分评论者. (如果我可以删除空白"注释,则可以,但是以后可以处理.)

I'd like to mimic how the comments look on my dashboard, without the user's icons and such, and with an alternating colour to help differentiate commentators. (Bonus if I can remove "blank" comments, but I can deal with that later.)

我已经做了一些搜索,但是只能找到如何获得交替的颜色.我确实看到一个帖子完全分解了评论,但我不理解代码他们提供了.

I've done some searching, but can only find how to get the alternating colours. I did see one post that broke down the comments completely, but I don't understand the code they provided.

我对HTML,CSS和jQuery还是很陌生,所以任何帮助将不胜感激!

I'm very new to HTML, CSS, and jQuery, so any help would be much appreciated!

推荐答案

@relgukxilef的答案几乎对我有用.

@relgukxilef's answer almost worked for me.

我必须将jQuery插入主题,然后等待jQuery初始化. Tumblr还更新了其标签.

I had to insert jQuery into the theme and then wait for jQuery to be initialised. Tumblr has also updated it's tagging.

这是我的解决方案:

<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>

<script type="text/javascript">
  $(document).ready(function () {
    // flatten reblogs
    $("div.post-content blockquote").each(function() {
      $(this).parent().prepend($(this).children());
      $(this).remove();
    });

    // remove : and add -
    $("div.post-content a.tumblr_blog").each(function() {
      var authorPTag = $(this).parent();
      authorPTag.html($(this));
      authorPTag.prepend("- ");
    });
  });
</script>

我将其添加到主题的底部,并且一切运行正常

I added this to the bottom of the theme and everything worked perfectly

这篇关于“嵌套"使用jQuery嵌套嵌套引用(以适应tumblr 2015年9月的更新)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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