I understand you want to browse an array of posts by clicking a next button. I would advise you to separate your post template, your post-browse functionality and the events that must trigger the change of post content.
For creating a template you could use Underscore's template function. Or EJS. And probably many other template libraries.
For manipulating the dom I would advise jQuery but you could do without.
Make sure all HTML is loaded before you try access elements in the page.
Visit this JS Fiddle
The markup:
<div id="post"></div>
<a href="#" id="next">next</a>
The code:
// A simple wrapper for your posts so your index variable cant be overwritten
// by some other peace of code
var posts = (function() {
// The template for the posts, using Underscore's template function
var tpl = _.template("<h2><%= title %></h2><p><%= content %></p>");
// The index of the current post
var index = 0;
// The array of posts
var posts = [
{title:"Title 1", content:'Bla bla lorem'},
{title:"Title 2", content:'Bla bla ipsum'},
{title:"Title 3", content:'Bla bla dolor'},
{title:"Title 4", content:'Bla bla sit'},
{title:"Title 5", content:'Bla bla amet'}
];
// The functions available to the document
return {
next:function(){
if(++index >= posts.length) {
index = 0;
}
return tpl(posts[index]);
},
load:function(){
return tpl(posts[index]);
}
}
}());
// Use of your posts object by the html document
document.getElementById('post').innerHTML = posts.load();
document.getElementById('next').onclick = function(){
document.getElementById('post').innerHTML = posts.next();
}