使整个博主帖子预览可点击

make whole blogger post preview clickable

本文关键字:      更新时间:2023-09-26

在我的网站上 www.beatmushroom.com 在博客平台上运行,我在主页上有我的帖子的小预览。要访问完整的帖子,您必须单击标题。 我希望能够单击帖子预览(缩略图和文本)上的任意位置,它将我带到帖子。我在想可能有某种方法可以用javascript做到这一点。

在主页的源代码中,一篇文章包含以下内容:

    <div class="date-outer">

    <div class="date-posts">
    <div class='post-outer'>
    <div class='post hentry'>
    <a name='366770510419642006'></a>
    <h2>
    <a href='http://www.beatmushroom.com/2012/05/logic-we-get-high.html'>Logic - We Get High</a>
    </h2>
    <div class='post-header'>
    <div class='post-header-line-1'></div>
    </div>
    <div class='post-body entry-content' id='post-body-366770510419642006'>
    <span class="tags">Rap</span><br>
    <img border="0" src="http://3.bp.blogspot.com/-qkVnjpTBMjY/T78PmQDUAvI/AAAAAAAAAKA/cUEMjJQ3w5s/s1600/logic.jpg">Here is a new one check it out logic has some good chilled tracks this has got a pretty old school feel to it. I am adding the blog to technorati. Technorati code: 886BP6K6GWA7<br>
    <div style='clear: both;'></div>
    </div>
    <div class='jump-link'>
    <a href='http://www.beatmushroom.com/2012/05/logic-we-get-high.html#more' title='Logic - We Get High'>&#9834; Listen Here &#187;</a>
    </div>
    <div class='post-footer'>
    <div class='post-footer-line post-footer-line-1'><span class='post-author vcard'>
    </span>
    <span class='post-timestamp'>
    </span>
    <span class='post-comment-link'>
    </span>
    <span class='post-icons'>
    <span class='item-control blog-admin pid-1598740620'>
    <a href='http://www.blogger.com/post-edit.g?blogID=4929692547831239344&postID=366770510419642006&from=pencil' title='Edit Post'>
    <img alt='' class='icon-action' height='18' src='http://img2.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/>
    </a>
    </span>
    </span>
    <div class='post-share-buttons goog-inline-block'>
    </div>
    </div>
    <div class='post-footer-line post-footer-line-2'><span class='post-labels'>
    </span>
    </div>
    <div class='post-footer-line post-footer-line-3'>
    <span class='post-location'>
    </span>
    </div>
    </div>
    </div>
    </div>

有没有办法从这里获取链接:

<h2>
<a href='http://www.beatmushroom.com/2012/05/logic-we-get-high.html'>Logic - We Get High</a>
</h2>

然后创建元素:

    <div class="date-outer">   

链接到那个?

由于帖子的其余部分位于该元素内,因此它将使帖子预览成为链接。然后他们将不得不单击背景,但我可能会使用 z-index 进行工作?

假设每个date-outer元素都包含一个包含单个锚点的二级标题本身:

$('.date-outer').each(function () {   
    $(this).click(function () {
        window.location = $('h2 a', this).attr('href');        
    });
});​

http://jsfiddle.net/WHd5d/1/

如果您希望

能够单击帖子中的任何内容并让它执行您想要的操作,请考虑使用*选择器

$('previewpost *').click(function() {
       doWhatever(); 
});
相关文章:
  • 没有找到相关文章