JavaScript从文件夹插入HTML片段

时间:2015-10-05 00:59:34

标签: javascript html css blogs

我想做一些事情,比如从我发布的博文中插入500个字符的片段。基本上我有一个文件夹,其中包含博客文章本身和一个页面,其中包含一堆链接到每个页面的片段。有点像WordPress。

基本上我想在JavaScript中做的是拥有一个代码,该代码将从博客文件夹中每个页面的特定CSS类中获取500字的代码段。

我制作了一个名为blog-post的自定义CSS类。我现在所拥有的只是:

var word_count = 500,
file = "General Computer Advice Blog Posts",
post = "blog-post",
cutoff = "...",
title_class = "title",
title,
posts[],
blog_post,
display_page = "page.aspx";

$(function () {
    // pseudo Code:
    foreach(var post in posts){
        title = post.get(title_class);//Get the title of the blog post
        blog_post = post.substring(0,word_count) + cutoff;//Get the first 500 characters and append ... to the end of it
        display_page.add(title);//Add the title of the post to the page
        display_page.add(blog_post);//Add the post snippet to the page
    }
}); 

0 个答案:

没有答案